Catching the termination of one script

Hi
I have a Shell script that needs to execute a command at the
End of the excursion of other script And I cant get a handel
On the trap command. And that is if the trap command
Is the proper way to go

this is a extract of the script

MYHOST=`hostname| cut -d. -f1`
echo $MYHOST

   cd /var/powerpassword/v3.4/ppsparc_solarisV-3.4.15-1/install
exec  ./ppinstall -b $MYMASTER  $MYHOST ;
#
########################################################
# Trap the successfull completion of ppinstal
########################################################
trap ppinstall 0
ppinstall()
{
  echo "Caught Signal ... ."
  ppadmin trace > /var/tmp/`hostname`-trace-result.txt
  echo "Done  ... quitting."
  exit 1
}

The 'exec' command means 'replace the shell with the command I give here'. After you run 'exec ./ppinstall' your shell no longer exists and can't trap anything. :slight_smile: Remove the exec and you won't need trap at all, since the shell script will continue running after ppinstall completes.

Yes thank you

     IJust dicovered that also. Now I have a nwe issue whit the same script

A loop that has issue :frowning:

MYVER=`uname -a | awk '{print $3}'`
   echo  $MYVER
{
   if  ["$MYVER" = "5.10"]
then
      /usr/sbin/svcadm disable telnet
else 
  /usr/sbin/ppadmin stop
}

Please put code in code tags. [ code ] stuff [ /code ] without the extra spaces in the tags.

MYVER=`uname -a | awk '{print $3}'`
   echo  $MYVER
{
   if  ["$MYVER" = "5.10"]
then
      /usr/sbin/svcadm disable telnet
else 
  /usr/sbin/ppadmin stop
}

What are the { } brackets for? This doesn't look like a function. Did you want to do something like this?

MYVER=`uname -a | awk '{print $3}'`
   echo  $MYVER

if  ["$MYVER" = "5.10"]
then
      /usr/sbin/svcadm disable telnet
else 
      /usr/sbin/ppadmin stop
fi

Hi All

I have resolved all my issues whit this
Script. Thank you all for you inputs

I�m posting the finished script fell free to criticize
And if it can be improved please tell me

#!/bin/sh
# Script to uninstall & install ppugrade
#
######################################################################
# Some variables
MYMASTER=server1
MYMASTSLAVE=server2
SUBJECT="Your rmote job is completed on `hostname`"
TO=user@company.com
SPOOLFILE=/var/tmp/`hostname| cut -d. -f1`-trace-result.txt
#####################################################################

## Move some files
    cd /etc/
    cp pam.conf pam.conf-preupgrade;
    echo Copying pam.conf pam.conf-preupgrade
    cp /etc/pam/ORIG /etc/pam.conf
    echo Copying /etc/pam/ORIG /etc/pam.conf
    mv /var/adm/ppserv.log  /var/ppserv.log-preupgrade #Getting a clean install log
#
#
## Check if we are Solaris 10

MYVER=`uname -a | awk '{print $3}'`
   if [ "$MYVER" = "5.10" ]
   then
   echo Execution de svcadm:  `/usr/sbin/svcadm disable powerpasswordt`
   else
             ppadmin stop
   fi
#
######################################################################
# Begin uninstall of PowerPassword
######################################################################
#
   cd /var/pp-old

   echo "\n\n Would you like to unistall powerpasswor on `hostname` (y/n)?"
    read YN
    #
    case $YN in
    [yY]*) echo Y |  ./ppuninstall
            ;;
    [nN]*) echo "Terminating gracefully TTFN .\n"
                exit 0
            ;;
    esac
#
##########################################################
# Begin install of PowerPassword
##########################################################
#

MYHOST=`hostname| cut -d. -f1`
    echo $MYHOST
    cd /var/powerpassword/v3.4/ppsparc_solarisV-3.4.15-1/install
   ./ppinstall -b $MYMASTER  $MYHOST ;
#
#   Move back some files
    cp /var/pp.orig/passwd /var/pp/passwd
    cp /var/pp.orig/pwhistory /var/pp/pwhistory
    cp /var/pp.orig/passwd.key  /var/pp/passwd.key
    cp /etc/pam.conf-preupgrade  /etc/pam.conf
#
########################################################
# Trap the successfull completion of ppinstal
########################################################
#
trap ppinstall 0

ppinstall()
  echo "Caught Signal ... ."
  ppadmin trace > /var/tmp/`hostname | cut -d. -f1`-trace-result.txt;
  echo "ppadmin trace is done check mail."
  echo "Sending the E-mail message..."
  /usr/bin/mailx -s "${SUBJECT}" ${TO} < $SPOOLFILE