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

Re: Changing parent process environment variable

by ikegami (Patriarch)
on Dec 20, 2007 at 21:17 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found