in reply to invoking umask command in perl

austin43:

As I understand it, umask is a built-in command in bash (I don't know about other shells). Not only that, but it only operates for the process that the shell is running in (I don't know about its descendents). So even if you do execute it, it will only affect the process that ends when the command returns to you.

You probably want to use the perl umask function (see umask documentation under perldoc perlfunc).

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: invoking umask command in perl
by austin43 (Acolyte) on Jun 01, 2011 at 18:14 UTC
    I tried using the built in perl umask function but it doesn't change the default umask for root. The script is running with root priveleges, but either using backticks or the built in perl umask function doesn't change the default umask for root.

      austin43:

      Right. If you want to change the default umask for root, then edit the .bashrc for root (assuming a bash shell). Perl's umask simply sets the umask for the currently-running perl script, it doesn't attempt to change the umask setting for anything else. Even in bash, running umask won't set the default value for root, it only sets the value used in the current session. That's why .bashrc and .bash_profile exist--to allow you to set up the account defaults.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.