comp.lang.ada
 help / color / mirror / Atom feed
* Create in a root directory (Linux)
@ 2015-10-28 17:31 comicfanzine
  2015-10-28 20:12 ` Simon Wright
  2015-10-29  7:00 ` comicfanzine
  0 siblings, 2 replies; 8+ messages in thread
From: comicfanzine @ 2015-10-28 17:31 UTC (permalink / raw)


Hi ,
I want to create a file in a root directory : "/"
And of course i am root . How can i proceed ? i always get the error : "permission denied" .

Here is the code that i tried :

[code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 

PROCEDURE TestFichier IS

   MonFichier : File_type ; 
   
BEGIN 
   Create( MonFichier,Name => " /clone.adb");
   close(MonFichier);
END TestFichier ;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-28 17:31 Create in a root directory (Linux) comicfanzine
@ 2015-10-28 20:12 ` Simon Wright
  2015-10-28 23:01   ` Paul Rubin
  2015-10-29  7:00 ` comicfanzine
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Wright @ 2015-10-28 20:12 UTC (permalink / raw)


comicfanzine@gmail.com writes:

> Hi ,
> I want to create a file in a root directory : "/"
> And of course i am root . How can i proceed ? i always get the error :
> "permission denied" .
>
> Here is the code that i tried :
>
> [code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 
>
> PROCEDURE TestFichier IS
>
>    MonFichier : File_type ; 
>    
> BEGIN 
>    Create( MonFichier,Name => " /clone.adb");
>    close(MonFichier);
> END TestFichier ;

What OS? which compiler?

I tried this on OS X and got Name_Error because of that extra space in
the name.

Fixed that; all OK now. So I don't know. (I do know that creating files
in your root directory is likely to be a Bad Idea).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-28 20:12 ` Simon Wright
@ 2015-10-28 23:01   ` Paul Rubin
  2015-10-29  6:41     ` comicfanzine
  2015-10-29  6:50     ` comicfanzine
  0 siblings, 2 replies; 8+ messages in thread
From: Paul Rubin @ 2015-10-28 23:01 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:
>>    Create( MonFichier,Name => " /clone.adb");

The problem is the leading space before the /


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-28 23:01   ` Paul Rubin
@ 2015-10-29  6:41     ` comicfanzine
  2015-10-29  6:50     ` comicfanzine
  1 sibling, 0 replies; 8+ messages in thread
From: comicfanzine @ 2015-10-29  6:41 UTC (permalink / raw)


Le jeudi 29 octobre 2015 00:01:49 UTC+1, Paul Rubin a écrit :
> Simon Wright <simon@pushface.org> writes:
> >>    Create( MonFichier,Name => " /clone.adb");
> 
> The problem is the leading space before the /

My fault i have not paste the code right , in fact the code whas without the space :

[code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 

PROCEDURE TestFichier IS

   MonFichier : File_type ; 
   
BEGIN 
   Create( MonFichier,Name => "/clone.adb");
  if Is_Open (MonFichier) then
   Put (Item => "Le fichier , ouvert ? : ", File => MonFichier);
end if;
END TestFichier ;[code/]
 I got the error : raised ADA.IO_EXCEPTIONS.USE_ERROR : /clone.adb: Permission denied

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-28 23:01   ` Paul Rubin
  2015-10-29  6:41     ` comicfanzine
@ 2015-10-29  6:50     ` comicfanzine
  1 sibling, 0 replies; 8+ messages in thread
From: comicfanzine @ 2015-10-29  6:50 UTC (permalink / raw)


Le jeudi 29 octobre 2015 00:01:49 UTC+1, Paul Rubin a écrit :
> Simon Wright <simon@pushface.org> writes:
> >>    Create( MonFichier,Name => " /clone.adb");
> 
> The problem is the leading space before the /

I use Linux = Ubuntu .
My fault i have not paste the code right , in fact the code whas without the space already :

WITH Ada.Text_IO ;  USE Ada.Text_IO ; 

PROCEDURE TestFichier IS

   MonFichier : File_type ; 
   
BEGIN 
   Create( MonFichier,Name => "/clone.adb");
   Close(MonFichier);
END TestFichier ;
[/code]I got the error :
raised ADA.IO_EXCEPTIONS.USE_ERROR : /clone.adb: Permission denied

Then how can i be recognize as "root" for create my file in this directory .


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-28 17:31 Create in a root directory (Linux) comicfanzine
  2015-10-28 20:12 ` Simon Wright
@ 2015-10-29  7:00 ` comicfanzine
  2015-11-01 14:23   ` Kevin K
  2015-11-03 11:12   ` M. Strobel
  1 sibling, 2 replies; 8+ messages in thread
From: comicfanzine @ 2015-10-29  7:00 UTC (permalink / raw)


Le mercredi 28 octobre 2015 18:31:29 UTC+1, comicf...@gmail.com a écrit :
> Hi ,
> I want to create a file in a root directory : "/"
> And of course i am root . How can i proceed ? i always get the error : "permission denied" .
> 
> Here is the code that i tried :
> 
> [code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 
> 
> PROCEDURE TestFichier IS
> 
>    MonFichier : File_type ; 
>    
> BEGIN 
>    Create( MonFichier,Name => " /clone.adb");
>    close(MonFichier);
> END TestFichier ;

Solved ! The solution was to execute the program in the terminal with "sudo" . That didn't work because i had execute the program from scite(my IDE) , and he don't recognize sudo .


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-29  7:00 ` comicfanzine
@ 2015-11-01 14:23   ` Kevin K
  2015-11-03 11:12   ` M. Strobel
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin K @ 2015-11-01 14:23 UTC (permalink / raw)


The simple solution.  I had assumed you were already running as root, or I would have suggested that.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create in a root directory (Linux)
  2015-10-29  7:00 ` comicfanzine
  2015-11-01 14:23   ` Kevin K
@ 2015-11-03 11:12   ` M. Strobel
  1 sibling, 0 replies; 8+ messages in thread
From: M. Strobel @ 2015-11-03 11:12 UTC (permalink / raw)


On 29.10.2015 08:00, comicfanzine@gmail.com wrote:
> Le mercredi 28 octobre 2015 18:31:29 UTC+1, comicf...@gmail.com a écrit :
>> Hi ,
>> I want to create a file in a root directory : "/"
>> And of course i am root . How can i proceed ? i always get the error : "permission denied" .
>>
>> Here is the code that i tried :
>>
>> [code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 
>>
>> PROCEDURE TestFichier IS
>>
>>    MonFichier : File_type ; 
>>    
>> BEGIN 
>>    Create( MonFichier,Name => " /clone.adb");
>>    close(MonFichier);
>> END TestFichier ;
> 
> Solved ! The solution was to execute the program in the terminal with "sudo" . That didn't work because i had execute the program from scite(my IDE) , and he don't recognize sudo .
> 

And, by the way, as an admin on Linux I would (in general) never allow such files on
my systems' root directory. There are quite some "standards" and a lot of best
practices telling where putting which files is best done.

/Str.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-03 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28 17:31 Create in a root directory (Linux) comicfanzine
2015-10-28 20:12 ` Simon Wright
2015-10-28 23:01   ` Paul Rubin
2015-10-29  6:41     ` comicfanzine
2015-10-29  6:50     ` comicfanzine
2015-10-29  7:00 ` comicfanzine
2015-11-01 14:23   ` Kevin K
2015-11-03 11:12   ` M. Strobel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox