in reply to how to set environment vars
sh scripts can only "source" sh scripts.
csh scripts can only "source" csh scripts.
Perl scripts can only "source" Perl scripts.
What we can do is have the run csh script and output its env variables in an easily parsable format. env can help us here. In fact, it can even be done without modifying the csh script — let's call it "script.csh" — using the following Perl code:
my $env = `csh -c 'source script.csh; env'`; foreach my $line (split("\n", $env)) { my ($key, $val) = split('=', $line, 2); $ENV{$key} = $val; }
Updated: I simplified my post by inlining the "wrapper script" into the executed command.
Updated: Added the closing backtick that was accidently deleted.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to set environmental vars
by rsennat (Beadle) on Nov 10, 2005 at 21:03 UTC | |
by ikegami (Patriarch) on Nov 10, 2005 at 21:05 UTC | |
by rsennat (Beadle) on Nov 11, 2005 at 11:05 UTC | |
by ikegami (Patriarch) on Nov 11, 2005 at 18:58 UTC |