in reply to UNIX environment setup via perl
#!/usr/bin/perl $ENV{JAVA_HOME}='/path/here'; # set other items in %ENV as appropriate exec '/usr/bin/ksh';
%ENV is your environment. Changes you make in it will be propagated to child processes. When you then exec the new shell, the changed environment carries over.
If you need to process a shell script to set variables, don't try to parse the script. Do something like:
foreach (`. $profile; env`) { chomp; next unless /=/; my ($var, $value) = split(/=/, $_, 2); $ENV{$var} = $value; }
This will execute the script and dump the environment in a straightforward format that you can parse.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: UNIX environment setup via perl
by perlisfun (Sexton) on May 07, 2004 at 22:48 UTC | |
by TomDLux (Vicar) on May 08, 2004 at 04:39 UTC |