Gigglesworth has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a Perl script. I need it to grab some environment variables from an Oracle environment script /oracle/oracle-env.sh . Certain environment variables such as "ORACLE_HOME" are set in that file.
If/when the DBA changes /oracle/oracle-env.sh , I want my script to automatically use the new environment, just like any Unix shell command. That is, if the DBA removes "ORACLE_HOME" and replaces it with "ORACLE_FOO", I want my script to pick up those changes.
In a shell script, you can by running the command "source /oracle/oracle-env.sh" or ". /oracle/oracle-env.sh".
In Perl, I know how to RUN a shell command from within a Perl script via `` or qx() .
However, this doesn't change the environment of my current Perl script-- e.g. the script still doesn't know about "$ORACLE_HOME", for example.
Is there an equivilant of the 'source' command within Perl?
Is the simplist solution to write a shell script as a wrapper, like this?
#!/bin/sh . /oracle/oracle-env.sh /path/to/perl/script/pl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl: Source shell script to for environment variables?
by Tanktalus (Canon) on Feb 08, 2006 at 02:24 UTC | |
|
Re: Perl: Source shell script to for environment variables?
by graff (Chancellor) on Feb 08, 2006 at 04:35 UTC | |
|
Re: Perl: Source shell script to for environment variables?
by brian_d_foy (Abbot) on Feb 08, 2006 at 07:26 UTC | |
|
Re: Perl: Source shell script to for environment variables?
by GrandFather (Saint) on Feb 08, 2006 at 02:07 UTC |