Hey Gang,

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

In reply to Perl: Source shell script to for environment variables? by Gigglesworth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.