Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Can you import ENV variables at run time?

by nardo (Friar)
on Jul 26, 2001 at 04:40 UTC ( #99864=note: print w/replies, xml ) Need Help??


in reply to Re: Can you import ENV variables at run time?
in thread Can you import ENV variables at run time?

/bin/bash isn't necessarily everyone's shell and thus any environment variables they set up upon login won't necessarily be set by bash.
$command = sprintf('exec - %s -c env', (getpwuid($>))[8]); $ENV{'HOME'} = (getpwuid($>))[7]; $env = `$command`;
This should run someone's shell as a login shell regardless of what shell it is, and $env will contain the output of env which should be easy to parse.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2022-05-29 04:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?