Sponsored Content
Top Forums Shell Programming and Scripting Catching the termination of one script Post 302355060 by Ex-Capsa on Monday 21st of September 2009 10:41:43 AM
Old 09-21-2009
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

Code:
#!/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


Last edited by Franklin52; 09-21-2009 at 11:47 AM.. Reason: Please use code tags!
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Abnormal Termination errors

I'm having trouble with Abnormal Termination errors. What are they, what causes them and how can I prevent them from happening? Are they application specific? (2 Replies)
Discussion started by: bialsibub
2 Replies

2. UNIX for Advanced & Expert Users

Child peocess termination.

Hello all, Here is the problem: A ksh script (let's call it abc.sh) gets kicked off from a menu program using "nohup abc.sh &". The process ID of abc.sh can be recieved (pid=$!). abc.sh runs an Oracle PL/SQL script (it creates a child process). In order to stop the abc.sh (and the child)... (5 Replies)
Discussion started by: Shaz
5 Replies

3. Shell Programming and Scripting

random script termination

I'm writing a script to archive data. First, the files are all rsync'd to the archive directory via NFS mounts(I know not the most efficient, but the only choice in this situation), then I use md5sum to validate the transfers. During execution of the script, it will exit for no apparent reason. It... (6 Replies)
Discussion started by: mph
6 Replies

4. Shell Programming and Scripting

Bash: Catching the returncode from a script and using within another script?

Hello, I want to run a bash script in another bash script, depending on the returncode or exitcode. But I don't know how to handover the returncode to the second bash script!? I tried this dummy script which should return the exit code 1 #test.sh echo "test" exit 1 But... (3 Replies)
Discussion started by: ABE2202
3 Replies

5. Shell Programming and Scripting

Problem with ssh termination...

hi all, i have a situation where i run ssh command from a unix machine to execute few scripts on 2 other unix machines. my problem is, the scripts that i run will start few commands on the 2 servers and will quit....i am able to quit from the script but i have to give ctrl+c (on the... (10 Replies)
Discussion started by: niteesh_!7
10 Replies

6. Shell Programming and Scripting

Cat termination in script

So, I'm writing a shell script to help automate a process I'm doing. Basically I want to take input from the user for 2 variables, then create a file that consists of: Variable1,Variable2 Constant1 Constant2 .. Constant2000 then run an awk script. I'm pretty new to unix though, and so... (11 Replies)
Discussion started by: Parrakarry
11 Replies

7. AIX

A question about scsi termination

http://ep.yimg.com/ay/iercomputer/ibm-39j5022-ultra320-scsi-adapter-dual-channel-pci-x-fc5736-3.gif I have bought this controller. Simple and fast question: I will put on this controller a external LTO tape,which is terminated with a terminator. I have to put another terminator on PCI-controller... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies

8. Shell Programming and Scripting

Script termination without pressing Enter key[nohup]

I have a script in which we have used nohup. Once script is executed it will be terminated only when enter key is pressed. I want the script to be terminated without pressing enter key nohup imqbrokerd -name user_id port 2>1 1>$home_`date` & I am a newbie to shell, Kindly please help (3 Replies)
Discussion started by: Suganbabu
3 Replies

9. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies
trap(1)                                                            User Commands                                                           trap(1)

NAME
trap, onintr - shell built-in functions to respond to (hardware) signals SYNOPSIS
sh trap [ argument n [n2...]] csh onintr [-| label] ksh *trap [ arg sig [ sig2...]] DESCRIPTION
sh The trap command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n). (Note: argument is scanned once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number or corresponding symbolic names. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11 (memory fault) produces an error. If argument is absent all trap(s) n are reset to their original values. If argument is the null string this signal is ignored by the shell and by the commands it invokes. If n is 0 the command argument is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. csh onintr controls the action of the shell on interrupts. With no arguments, onintr restores the default action of the shell on interrupts. (The shell terminates shell scripts and returns to the terminal command input level). With the - argument, the shell ignores all inter- rupts. With a label argument, the shell executes a goto label when an interrupt is received or a child process terminates because it was interrupted. ksh trap uses arg as a command to be read and executed when the shell receives signal(s) sig. (Note that arg is scanned once when the trap is set and once when the trap is taken.) Each sig can be given as a number or as the name of the signal. trap commands are executed in order of signal number. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. If arg is omitted or is -, then the trap(s) for each sig are reset to their original values. If arg is the null (the empty string, e.g., "" ) string then this signal is ignored by the shell and by the commands it invokes. If sig is ERR then arg will be executed whenever a command has a non- zero exit status. If sig is DEBUG then arg will be executed after each command. If sig is 0 or EXIT for a trap set outside any function then the command arg is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), exit(1), ksh(1), sh(1), attributes(5) SunOS 5.10 23 Oct 1994 trap(1)
All times are GMT -4. The time now is 09:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy