Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^6: invoking umask command in perl

by austin43 (Acolyte)
on Jun 01, 2011 at 19:18 UTC ( [id://907698]=note: print w/replies, xml ) Need Help??


in reply to Re^5: invoking umask command in perl
in thread invoking umask command in perl

I don't understand.

Replies are listed 'Best First'.
Re^7: invoking umask command in perl
by shmem (Chancellor) on Jun 01, 2011 at 19:39 UTC

    By altering a copy, you won't change the original. The perl program gets its environment and bits and settings from the invoking process, and that one (e.g. a root shell) won't change its mind just because perl is twiddling its own copy of the big picture. There are tricks to swap copy and original, but these involve changing system files. And even so, if you change things behind the back of the program which invoked perl, it just won't notice. For an effective and persistent change of umask usually a new process chain is necessary, starting with login(1).

Re^7: invoking umask command in perl
by Jenda (Abbot) on Jun 02, 2011 at 12:43 UTC

    If there is a builtin or a function in a preinstalled library, do not start an external program, use the builtin/function.

    In most cases it's just a waste of resources, in this particular case it just won't work. The reason is that the umask does something to the shell that executes the command and the programs started later by the shell, not the program that started the shell.

    Your Perl script starts a program (/bin/sh or something - the "shell" we've been talking about) and asks it to execute the "umask" command. The shell executes the command, changes ITS OWN user mask and exits.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-20 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found