Can anyone answer the following puzzler - I have a work-round but the reason/cause for this problem is intriguing me. A former colleague wrote a Perl Module called sectran.pm which is widely used to transfer files from server to server etc. Part of the requirement for running this script is to have the following in your calling script -
use lib "$ENV{'SECTRAN_DIR'}/lib" ; use sectran ;
In most users this works but our production user - interface - didn't have the SECTRAN_DIR environment variable set, after correcting this any script calling sectran works. But only at the command line. When trying to run scripts via the interface cron they fail as the SECTRAN_DIR variable is not being found. Initially I thought this was the old chestnut about the interface cron not calling the local .profile so I included said call in my script.
if (exists $ENV{HOME}) { $file = "$ENV{HOME}/.profile" ; if (! -x $file) { print "\n\tUnable to execute the $file from the current user!\n" +; print "\n\tInsufficient permissions!\n" ; $result = 99 ; } else { open INP,"<$file" or die "\n\tfitz yer gem min?" ; while (<INP>) { print $_ } close INP or die "\n\tA canny dee it min!\n" ; # print "\n\tRunning $file.\n" ; $result = system "$file" ; print "\n\tResult set to $result\n" ; } # } else { print "\n\tNo profile file found!\n" ; $result = 98 ; }
This prints out the .profile file that it has executed -
TERM=vt220; export TERM PATH=/usr/local/bin:/usr/bin:/usr/ucb:/etc:/isw/tpp/oracle/live/1.6.1/ +ids/bin:/i sw/tpp/oracle/live/1.6.1/ids/forms60/mesg:/isw/appwork/live/finance/gu +ifmxs:. EDITOR=vi ;export EDITOR umask 002 ORACLE_TERM=vt220 ; export ORACLE_TERM ORACLE_SID=ISWLIVE ; export ORACLE_SID ORACLE_HOME=/isw/tpp/oracle/live/8.1.7; export ORACLE_HOME PATH=$PATH:${ORACLE_HOME}/bin:${ORACLE_HOME}/dbs export PATH LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/usr/lib:/usr/ucblib export LD_LIBRARY_PATH PS1='${ORACLE_SID} > ' PS2='?' SECTRAN_DIR=/home/interface/sectran export SECTRAN_DIR TWO_TASK=isw-live; # Addition to allow ORACLE Forms testing in TEST & Other environments +- Bob alias ISWTEST='ORACLE_SID=ISWTEST ; export ORACLE_SID; \ ORACLE_HOME=/isw/tpp/oracle/test/8.1.7; export ORACLE_HOME \ LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/ucblib export LD_LIBRARY_PATH PATH=/usr/local/bin:/usr/bin:/usr/ucb:/etc:/isw/tpp/oracle/test/1.6.1/ +idst/bin:/ isw/tpp/oracle/test/1.6.1/idst/forms60/mesg:/isw/appwork/test/finance/ +guifmxs:. PATH=$PATH:${ORACLE_HOME}/bin:${ORACLE_HOME}/dbs export PATH' # ISWLIVE alias ISWLIVE='ORACLE_SID=ISWLIVE ; export ORACLE_SID; \ ORACLE_SID=ISWLIVE ; export ORACLE_SID ORACLE_HOME=/isw/tpp/oracle/live/8.1.7; export ORACLE_HOME LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/usr/lib:/usr/ucblib export LD_LIBRARY_PATH PATH=/usr/local/bin:/usr/bin:/usr/ucb:/etc:/isw/tpp/oracle/live/1.6.1/ +ids/bin:/i sw/tpp/oracle/live/1.6.1/ids/forms60/mesg:/isw/appwork/live/finance/gu +ifmxs:. PATH=$PATH:${ORACLE_HOME}/bin:${ORACLE_HOME}/dbs export PATH' # ISWTEACH alias ISWTEACH='ORACLE_SID=ISWTEACH ; export ORACLE_SID; \ ORACLE_SID=ISWTEACH ; export ORACLE_SID ORACLE_HOME=/isw/tpp/oracle/general/8.1.7; export ORACLE_HOME LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/usr/lib:/usr/ucblib export LD_LIBRARY_PATH PATH=/usr/local/bin:/usr/bin:/usr/ucb:/etc:/isw/tpp/oracle/general/1.6 +.1/ids/bin :/isw/tpp/oracle/general/1.6.1/ids/forms60/mesg:/isw/appwork/general/f +inance/gui fmxs:. PATH=$PATH:${ORACLE_HOME}/bin:${ORACLE_HOME}/dbs export PATH'
Bear with me as we are getting to the crux of the problem now.This made no difference - SECTRAN_DIR still did not exist. I then added code to print out the ENV hash which I foolishly thought should reflect the .profile listed -
# while (($key, $value) = each (%ENV)) { print "\n\tKey :: $key" ; print "\n\tValue :: $value" ; }
Imagine my surprise then when the following was output -
Running /home/interface/.profile. Result set to 0 Key :: HOME Value :: /home/interface Key :: LOGNAME Value :: interface Key :: SHELL Value :: /usr/bin/sh Key :: TZ Value :: GB Key :: PATH Value :: /usr/bin:
Does anyone understand this? I can find no trace of any .profile to reflect the results in the ENV hash table! Cheers, Ronnie

In reply to Perl/UNIX .profile problem 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.