Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Changing parent process environment variable

by ikegami (Patriarch)
on Dec 20, 2007 at 21:17 UTC ( #658267=note: print w/replies, xml ) Need Help??


in reply to Changing parent process environment variable

Have the child output the set commands instead of executing it, and process the commands in the parent.

If the parent is a Perl script:

chomp( my @cmds = `child` ); foreach my $cmd (@cmds) { next unless /^set\s+(\S.*?)=(.*)/i; $ENV{$1} = $2; }

If the parent is a batch file:

for /f "usebackq delims=" %%f in (`child`) do %%f

The child would output such as

echo set VAR=5
or
print("set VAR=5\n");

Update: Added second snippet.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2023-02-04 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?