in reply to Unix Aliases?
This solution is assuming to find the file $profile in the PATH of the caller.sub getenv { my $profile = shift; my @envlines = (`exec ksh -c ". $profile; env"`); foreach (@envlines) { chomp; next unless /=/; my ($var, $value) = split(/=/, $_, 2); $ENV{$var} = $value; } } # END - getenv
We would then call our sub like:#!/bin/ksh export ORACLE_SID=testp export NLS_LANG=American_America.WE8ISO8859P1 export ORACLE=/opt/oracle
getenv would execute my_env in a shell. The second command "env" would create output like:getenv ('my_env');
These will be written into @envlines and then be set into the running Perl script's environment.ORACLE_SID=testp NLS_LANG=American_America.WE8ISO8859P1 ORACLE=/opt/oracle
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unix Aliases?
by Ronnie (Scribe) on Sep 07, 2004 at 13:02 UTC | |
by ikegami (Patriarch) on Sep 07, 2004 at 16:51 UTC | |
by Ronnie (Scribe) on Sep 08, 2004 at 08:53 UTC | |
by pelagic (Priest) on Sep 08, 2004 at 09:24 UTC | |
by Ronnie (Scribe) on Sep 08, 2004 at 10:05 UTC | |
|