Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Can you import ENV variables at run time?

by lestrrat (Deacon)
on Jul 26, 2001 at 05:49 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2022-08-10 23:50 GMT
Find Nodes?
    Voting Booth?

    No recent polls found