in reply to Environment setting using shell
my $SID=shift; my $output=`. /my_location/switchdb.ksh $SID 2>/dev/null 1>/dev/null & +& echo \$ORACLE_HOME`; chomp($output); if($output =~ m{/}){ $ENV{ORACLE_HOME} = $output; } print "DEFINED ORACLE_HOME as (" . $ENV{ORACLE_HOME} . ")\n";
Note that I do not execute, I source the script. Then request the variable with and (&&)
in a similar fashion, if you need more environment variables, dump them with env:
my $output=`. /my_location/switchdb.ksh $SID 2>/dev/null 1>/dev/null & +& env > /tmp/$mytempfile`;
then read the file back and split(/=/,$line,2) to get the key and the value, and put them in %ENV
|
|---|