I'm trying to use the code Tilly supplied re picking up an environment from a parent process - I tried this some time ago but time was pressing so I ended up just creating the environment by copying the details from the shell script into my own Perl version....tedious beyond belief! I'm now working on a much bigger application who's default environment is created by 2 shell scripts and would be WAY too tiresome to replicate. I think I know what her script does but wondered if the error I'm getting is as a result of how our environment looks.

Sample
OLDHOME=${ORACLE_HOME} ; export OLDHOME unset TWO_TASK; ORACLE_SID=IHSLIVE ; export ORACLE_SID ORACLE_BASE=/ihs/tpp/oracle/live ; export ORACLE_BASE ORACLE_DOC=${ORACLE_BASE}/doc ; export ORACLE_DOC ORACLE_HOME=${ORACLE_BASE}/9.2.0 ; export ORACLE_HOME ORACLE_PAGER=/usr/bin/pg ; export ORACLE_PAGER ORACLE_LPSTAT=/usr/bin/lpstat ; export ORACLE_LPSTAT ORACLE_LPPROG=/usr/bin/lp ; export ORACLE_LPPROG ORACLE_LPARGS='-o nobanner' ; export ORACLE_LPARGS #

Yes before anyone else tells me, it's a mess but it's supplied by a third party and we are NOT allowed to change it.....
The code I'm using for test purposes is -
#!/usr/bin/perl -w # use strict ; # sub get_login_env { local %ENV; # my $shell = shift || (getpwuid($<))[8]; # # I know that the shell we use is the ksh # # my $shell = '/bin/ksh' ; my $env = `echo env | perl -e 'exec {"$shell"} -sh'`; if (wantarray) { my @pieces = ($env =~ m/^(.*?)=((?:[^\n\\]|\\.|\\\n)*)/gm ); s/\\(.)/$1/g foreach @pieces; return @pieces; } else { return $env; } } # # Variables #----------# my $result = undef ; # Processing #----------# print "\n\t\tPlay with ENV starts\n" ; $result = system(". /opt/bin/oraIHSLIVE.env") ; # print "\n\tRES :: $result\n" ; if ($result) { print "\n\t\tRes :: $result\n" ; print "\n\t\tBombing Out (1)\n" ; exit 122 ; } # $result = system(". /opt/bin/fsw.env IHSLIVE") ; # if ($result) { print "\n\t\tRes :: $result\n" ; print "\n\t\tBombing Out (2)\n" ; exit 123 ; } # %ENV = (%ENV, get_login_env()); print "\n\t\tPlay with ENV ends\n" ;
This produces an error which I'm guessing may be caused by the format of our packages environment.The error generated is
$ xxrc_pickup_env.pl Play with ENV starts RES :: 0 Environment variable ADMIN_DIR is not set grep: can't open a grep: can't open tty Play with ENV ends
Ignoring the ADMIN_DIR message - well we do apparently! - does this mean that tilly's code won't work with the format of our environment? If so I suppose I better get typing....for the next X days!

In reply to Parent Process Environment by Ronnie

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.