in reply to Re^2: passing env{} variable to child fails on linux,works on windows
in thread passing env{} variable to child fails on linux,works on windows
well, there it is then.. its not a 'child' its a peer..Flexvault is mistaken. It's a child, and it does inherit environment variables. Here are a couple of linux scripts that demonstrate this. First, /tmp/myenv just prints any environment variables that have 'MY' in the name:
Then the main script, which 'opens' myenv:#!/usr/bin/perl print "$_=>$ENV{$_}\n" for grep /MY/, sort keys %ENV;
Running this gives:#!/usr/bin/perl $ENV{MYA} = 'a'; $ENV{MYB} = 'b'; $ENV{C} = 'c'; open(CMD, "/tmp/myenv 2>&1 |") or die "open: $!\n"; while (<CMD>) { chomp; print "got: <$_>\n"; }
got: <MYA=>a> got: <MYB=>b>
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: passing env{} variable to child fails on linux,works on windows
by sdetweil (Sexton) on Jan 13, 2013 at 13:39 UTC | |
by andal (Hermit) on Jan 14, 2013 at 09:19 UTC | |
by thargas (Deacon) on Jan 14, 2013 at 13:49 UTC |