perlquestion
Ronnie
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 -
<code>
use lib "$ENV{'SECTRAN_DIR'}/lib" ;
use sectran ;
</code>
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.
<code>
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 ;
}
</code>
This prints out the .profile file that it has executed -
<code>
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/guifmxs:.
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/guifmxs:.
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/finance/gui
fmxs:.
PATH=$PATH:${ORACLE_HOME}/bin:${ORACLE_HOME}/dbs
export PATH'
</code> 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 -
<code>
#
while (($key, $value) = each (%ENV)) {
print "\n\tKey :: $key" ;
print "\n\tValue :: $value" ;
}
</code>
Imagine my surprise then when the following was output -
<code>
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:
</code>
Does anyone understand this? I can find no trace of any .profile to reflect the results in the ENV hash table!
Cheers,
Ronnie