Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: File Permissions

by bikeNomad (Priest)
on Jul 22, 2001 at 22:52 UTC ( [id://98854]=note: print w/replies, xml ) Need Help??


in reply to File Permissions

There is a per-process setting called umask that serves to reset permission bits. In your case, the umask is apparently 0113.

Just use the perl umask built-in to change this for your process (only need to do it once):

umask 0; chmod 0777, $file;

However, do you really want rwx permissions for everyone?

update: Randal's right; I assumed that umask worked on chmod too, but it doesn't.

Replies are listed 'Best First'.
Re: Re: File Permissions
by merlyn (Sage) on Jul 22, 2001 at 23:02 UTC
    No, that can't be it. chmod is not affected by the umask. Only making a new file or new directory.

    I can't tell... is this a web script (if so, it's very dangerous) or a command-line script?

    -- Randal L. Schwartz, Perl hacker

      This is command line. 0777 is just for testing--the data it's copying at the moment needs 777, but eventually it'll be something more like 750 or 550.
Re: Re: File Permissions
by Anonymous Monk on Jul 23, 2001 at 00:32 UTC
    Aha! I found the problem. Later on in the script, some changes were made to the newly copied files--that is, a reader handle was opened on it, the unaffected parts were copied to a writer handle (opened on filename.ext.new), the new data was sent to the writer, and the remainder of the file copied over as well. Then the streams were closed, the original was unlinked, and the .new file was renamed in it's place. The umask was causing problems with the new file that was created by the writer, and setting umask(0) fixed it. Silly me. =) Thanks for the help guys!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98854]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found