#! /bin/sh

#    Sep 06/01 - F.Majaess 
#
#id  nohupme - Used to facilitate Cross compilation remotely by
#id            invoking "nohup" via "rsh".
#
#    AUTHOR  - F.Majaess
#
#  PURPOSE - "nohupme" script is employed by the remote Cross compiler
#            script invoking "nohup" on the command, output and error 
#            target arguments specified via "rsh".
#
#pr PARAMETERS:
#pr
#pr   POSITIONAL
#pr
#pr     arg1    = "command" to execute.
#pr
#pr     arg2    = Output file destination.
#pr
#pr     arg3    = Error file destination.
#pr               (redirected to "arg2" if no "arg3" is specified)

#ex EXAMPLE:
#ex
#ex   nohupme /tmp/tmp_dir/command /tmp/tmp_dir/out /tmp/tmp_dir/err
#ex

if [ -n "$1" -a -n "$2" ] ; then
 if [ -n "$3" ] ; then
  exec /bin/nohup $1 >> $2 2>> $3 &
 else
  exec /bin/nohup $1 >> $2 2>> $2 &
 fi
 sleep 3
 Accnt=`whoami`
#Prcss=`\ps -l -u $Accnt | egrep 'UID|f90com'`
 Prcss=`\ps -l -u $Accnt | sed -n -e '/ UID /p' -e '/  0:0. f90com/p'`
 echo "$Prcss"
 exit
else
 echo '\n0 nohupme: ERROR, insufficient arguments specified in the call!'
 exit 1
fi
