Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

because of the latest answer to your post, i have just seen your post and answering now.

In linux I can enquire umask using /usr/bin/umask. In my case, env does not report anything about umask. Umask is usually set when a shell like bash starts. For bash that happens probably via ~/.bashrc, /etc/bashrc, /etc/profile. But for other shells, like csh it could be in other files. So, each shell has its own configuration setup and somewhere in there should be a umask. Of course you could insert one yourself umask 022 at the end of your ~/.bashrc and that will overwrite any previous umask settings.

When you run system("env ...") you will get the ENV of some shell that Perl spawns via system(). (In my system that's sh). When you run system("xterm") you will create an xterm which will then launch a shell. Now which shell will that be? Perhaps $XTERM_SHELL can give you a hint. The new shell will inherit environment from parent and also read configuration from rc files. Sometimes Perl's system() will not launch a new shell just to run your command but instead it will run the command directly if it's possible. So, if it launches a shell, that could be sh. (In my system, system("xterm") causes Perl to run a sh -c xterm which in turn spawns a bash shell.) It will then read some configuration files, and then run xterm which launches yet another shell which inherits env from parent shell and also reads some configuration from its own rc files. If your current shell is bash but xterm launches sh, then it's possible to have different umasks.

Regarding ENV inheritance, the following says it all, it creates a shell within a shell which had its umask chamged. The new shell inherit's parent shell's umask:

% umask 0002 % umask 0 % umask 0000 % bash %% umask 0000 %% exit

Bottomline: there are a lot of shells being spawned, one inside the other in what you are doing. Shells inherit their environment (and also umask) from parent shells. They also configure using rc files (like ~/.bashrc). If you can find which shell your xterm runs then you can edit its configuration and alter its umask. Alternatively, force xterm to launch the shell you want which reads from the rc file you want:system("echo 'umask 03' > mybashrc; xterm -e '/bin/bash --rcfile mybashrc'"); . For me, this creates an xterm running bash with umask 0003.


In reply to Re^7: umask when calling xterm from perl by bliako
in thread umask when calling xterm from perl by Special_K

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-19 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found