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

Re: Can you import ENV variables at run time?

by lestrrat (Deacon)
on Jul 26, 2001 at 05:49 UTC ( [id://99872]=note: print w/replies, xml ) Need Help??


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

Thank you both!

I think this is what I'm going to do:

use Env; ## uid = 0 at this point. ## delete root's env foreach my $key ( keys %ENV ) { delete $ENV{ $key }; } ## set standard PATH, apparently some scripts ## rely on this $ENV{ PATH } = '/bin:/usr/bin:/usr/local/bin:/usr/ucb'; $> = $target_uid; $< = $target_uid; my( $shell, $home ) = ( getpwuid( $> ) ) [ 7, 8 ]; $ENV{ HOME } = $home; my $env_str = qx/exec $shell -c env/; # now parse

Replies are listed 'Best First'.
Re^2: Can you import ENV variables at run time?
by tadman (Prior) on Jul 26, 2001 at 18:47 UTC
    Any reason you couldn't do something like:
    %ENV = ( HOME => $home, PATH => '/bin:/usr/bin:/usr/local/bin:/usr/ucb', );
    Seems a lot simpler than explictly deleting every key of %ENV, and then inserting things one by one.

Log In?
Username:
Password:

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

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

    No recent polls found