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

No...I simply don't understand how to invoke the shell to use this function. I understand the issue comes from the same source, but all my attempts at implementing similar measures to fix my problem failed. I also have looked at different sources of information to gain knowledge about the umask command. Before you accuse someone of 'blindly' taking a solution, make sure the person isn't just new to linux and perl. I am still learning the ropes of both linux and perl, and it becomes hard to learn when everyone expects you to understand exactly what is happening when you are already trying to understand simpler aspects of the problem.

Replies are listed 'Best First'.
Re^5: invoking umask command in perl
by Corion (Patriarch) on Jun 01, 2011 at 19:16 UTC

    The idea is to not invoke the shell.

      I don't understand.

        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).

        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.