You seem to be misunderstanding two things.

  1. Perl starts a new shell each time you call system or use backticks.
  2. A child process cannot modify the environment of its parent process. (This is generally regarded as a good thing.)
Keep those two things in mind and you'll understand why lines like `export ORAENV_ASK ORACLE_SID ORACLE_HOME`; are completely useless. It simply doesn't make sense to start a shell, export some envariables (which haven't even been set), and then exit the shell.

You can use a method such as runrig suggested; run a child process and then copy the child's environment into perl's. Or you can just set perl's environment in the first place. If you can be sure your shell script won't contain anything but simple variable assignments, parsing it directly wouldn't be too difficult. (Be forewarned that you'll be forever limited in the complexity of the shell script though.)

Finally, you also should keep in mind that perl uses /bin/sh to execute commands in backticks or when you call system with a single argument that contains shell metacharacters. Unless /bin/sh is really a Korn shell in your environment you should be careful of compatibility issues.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: How to execute a Korn shell ". <some-file>" from within Perl by sauoq
in thread How to execute a Korn shell ". <some-file>" from within Perl by blink

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.