Re: How to set file attributes
- From: Ron Bergin <rkb@xxxxxxxxxx>
- Date: Wed, 27 Feb 2008 10:20:12 -0800 (PST)
On Feb 26, 10:27 pm, John <John.Sm...@xxxxxxxxxxx> wrote:
Jim Gibson <jimsgib...@xxxxxxxxx> wrote:
In article <38t8s3550b7tipdjlg66u2ddmv8683k...@xxxxxxx>, John
<John.Sm...@xxxxxxxxxxx> wrote:
I have set up my own counter.pl on my web page.
The counter saves the visitation count to a text file called "count.txt".
How do I create the file (and later open) with file attributes that prevent
others reading the file, ie. going towww.johnsmith.com/count.txt (the www
here
is not real).
It depends upon the operating system. Under Unix, you would create the
file with an editor, the cat command, or the touch command (see 'man
cat', etc.). File permissions are set with the chmod command. You want
to set the file so that it is readable and writable only by the owner:
chmod 0600 count.txt
The problem is that for this to work, the file needs to be owned by the
web server process, and that may not be your own user id. Some web
servers use the user 'nobody', for example. As a result, you sometimes
have to set data files to be world writable:
chmod 0666 count.txt
So it also depends upon your user id, the web server's id, and whether
or not you have root privilege.
If you do have root privilege, then you can set the owner of the file
as well as the file permissions (as above):
chown nobody:nobody count.txt
chmod 0600 count.txt
But this is for Unix, not necessarily other operating systems.
Thanks for input. The web counter files should be seen my me only (I download the
files every day).
Setting the files chmod 0600 count.txt seems to do what I want.
The perl script creates a num conter file for every day. How do I create the new
file so that it has 0600 attributes?
$txtfi=open (MYCOUNT,"<"."count.txt");
use File::CounterFile;
http://search.cpan.org/~gaas/File-CounterFile-1.04/CounterFile.pm
The module uses sysopen without specifying the perm (which defaults to
0666) so you'd probably what to adjust the code in the module.
change:
sysopen(F, $file, O_RDWR|O_CREAT) or croak("Can't open $file: $!");
to:
sysopen(F, $file, O_RDWR|O_CREAT, 0600) or croak("Can't open $file:
$!");
.
- References:
- How to set file attributes
- From: John
- Re: How to set file attributes
- From: Jim Gibson
- Re: How to set file attributes
- From: John
- How to set file attributes
- Prev by Date: Re: How to set file attributes
- Next by Date: Re: How to set file attributes
- Previous by thread: Re: How to set file attributes
- Next by thread: Re: How to set file attributes
- Index(es):
Relevant Pages
|
|