[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference smurf::ase

Title:ase
Moderator:SMURF::GROSSO
Created:Thu Jul 29 1993
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2114
Total number of notes:7347

1921.0. "Bourne Shell start script variable problem." by SCASS1::FIFE (Dean Fife, on site consultant HUGHES Corp.) Wed Mar 05 1997 21:13

    I am having a problem with a user defined script for ase 1.3 (osf
    3.2g).
    
    The customers script runs find outside of ASE but failes inside of it.
    I traced it down to be the $SHELL variable. A script that was called
    tests to see what shell invoked it (no #!/bin/sh) and if it is the
    wrong shell it exits. It is easy enough to fix but I can't explain why
    the $SHELL variable is not valid if you invoke a bourne shell script
    from within ASE. I can duplicate the problem with the following...
    
    1) Create user defined script that has the following start action...
    
    #!/bin/sh
    echo $SHELL 1 > /tmp/test
    /tmp/1
    
    The file /tmp/1 has the following...
    
    echo $SHELL 2 >> /tmp/test
    /tmp/2
    
    The file /tmp/2 has the following...
    
    echo $SHELL 3 >> /tmp/test
    
    2) Put the service online so the start action script runs...
    3) This is the value of the /tmp/test file.
    
    /bin/sh 1
    /bin/sh 2
    3
    
    But if I just do a /tmp/1 it works fine. The start script and the first
    file it envokes has the $SHELL value set, but any further scripts down
    the line do not.
    
    Any thoughts..
    
    Thanks...
    
    Dean Fife
    
T.RTitleUserPersonal
Name
DateLines
1921.1It worked on my systemsNETRIX::"myrdal@zk3.dec.com"Gregory P. MyrdalThu Mar 06 1997 14:1668
I hate to say it, however, it seemed to work for me.  I got the same results
when the scripts where run inside of ASE and outside:

#!/bin/sh
echo $SHELL 1 > /tmp/test
/tmp/1

/tmp/1:
echo $SHELL 2 >> /tmp/test
/tmp/2

/tmp/2:
echo $SHELL 3 >> /tmp/test

/tmp/test (output):
/bin/sh 1
/bin/sh 2
/bin/sh 3

It appears from the ksh man page that SHELL is set at login time so I would
not
think the variable would be reset during shell invoke time.  The sh man page
did not mention anything about resetting the SHELL variable.

  The shell gives default values to PATH, PS1, PS2, MAILCHECK, TMOUT, and
  IFS, while HOME, SHELL, ENV, and MAIL are not set by the shell (although
  HOME is set by the login command).  On some systems, MAIL and SHELL are
  also set by the login command.


As far as ASE goes, it just puts your start script into a temporary file
and executes it:

cat > ${SH} 2> ${LOGGER}

chmod +x ${SH} >> ${LOGGER} 2>&1

${SH} $* >> ${LOGGER} 2>&1
returnValue=$?

If you want to know what shell is being run, I wonder if you are doing the
correct check.  Note the man page above mentions that the SHELL variable
may only be set at login time.  With this info I wrote the following
scripts and got the following results.  Note that $SHELL did not really
tell me which shell I was running:
# echo $SHELL
/bin/sh
#
# cat /tmp/c
#!/usr/bin/csh
echo ${SHELL}
#      
# /tmp/c
/bin/sh
# 
# cat /tmp/k
#!/usr/bin/ksh
echo ${SHELL}
# 
# /tmp/k
/bin/sh
# 


-- Greg


[Posted by WWW Notes gateway]