trapping errors from a sub call


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trapping errors from a sub call
# 1  
Old 04-29-2009
trapping errors from a sub call

I want to trap any errors from a backup database script and send an email when an error occurs. I can trap command errors and send an email in the following code. My problem occurs if an error occurs in the Maxl script, /opt/hyperion/AnalyticServices/bin/essmsh < MaxlScript.msh..., that is called to back up the database. Is there a way I can trap an error that is returned from the Maxl script.

Code:
#!/usr/bin/ksh -v
error_message()
{
   mailx -s "Essbase backup error" email user Id.  < BackupError.txt
}
trap 'error_message' ERR
set -e
cd /opt/hyperion/HYP_BACKUP/scripts
/opt/hyperion/AnalyticServices/bin/essmsh < /opt/staff/srv-plan9/MaxlScript.msh > /opt/staff/srv-plan9/Maxl.log 2>$1
exit

Thanks,
Tom
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trapping the error during copy

I have a requirement: During copy command for example: cp -rf <sourceDir> <destinationDir> this command may fails for many reasons like: 1. source or destination directory does not exist 2. destination directory does not have sufficient space 3. directories are not mounted ... Or may... (3 Replies)
Discussion started by: ambarginni
3 Replies

2. Shell Programming and Scripting

Error Trapping

Hi, I have one shell script as below while read SegList do if test -s ${SourceFile_Path}/${Segment_List_Temp} then ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ|cut -d '.' -f2>>${SourceFile_Path}/${List_Temp} echo "IF above statment Fail I want to Create Emtpy File How to Trapp... (3 Replies)
Discussion started by: samadhanpatil
3 Replies

3. Shell Programming and Scripting

trapping sftp errors

I'm trying to trap errors in a shell script executing an sftp command this way: /usr/bin/sftp $FTP_USER@$FTP_SERVER <<EOF> $HOME/$ERR_FILE cd $FTP_DIR put $FILE_NAME bye EOF I expect errors to be recorded in $ERR_FILE but they are not. The only thing in the $ERR_FILE is: sftp> sftp>... (2 Replies)
Discussion started by: pochon
2 Replies

4. Solaris

System call trapping using ptrace.

Hello experts, I am trying to trap system calls using ptrace available on Salaris. How to get the system call number which I am going to trap. In Linux I have done like below: ptrace(PTRACE_PEEKUSER, pid, 4 * ORIG_EAX, NULL); where PTRACE_PEEKUSER : is the request, this specifies the... (1 Reply)
Discussion started by: Patel
1 Replies

5. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

6. UNIX for Dummies Questions & Answers

trapping errors

I am using unixs script to submit programs (SQRS) and need to trap any time of error that is received once the job finishes. Examples of the type of errors I am getting Error! SQR Failed To Process mkdir: Failed to make directory These are showing up in a log file but I do not want to... (3 Replies)
Discussion started by: TimHortons
3 Replies

7. Shell Programming and Scripting

Trapping $! output

hey all, I have a script that creates and then distributes html files via scp on a 60 second cycle. On occasions the scp will hang and not complete with the cycle. When running the scp command in the back ground it returns the PID. How do I trap $! in the script? job=`echo $!` returns... (2 Replies)
Discussion started by: nhatch
2 Replies

8. Shell Programming and Scripting

trapping errors while using FTP.

Hello, I have the following shell script to perform ftp: ftp -n $HOST<<EOD quote USER $USER quote PASS $PASS lcd $outputd cd $dir binary put *.zip quit EOD If any error is generated from this script then how to trap the error. For ex: let's say we entered wrong password then the... (5 Replies)
Discussion started by: radhika
5 Replies

9. Shell Programming and Scripting

Error Trapping

Hi, Can anybody tell me how to error trap an empty line. If i am asked for a password and I hit enter without entering any text, how do i display an error? Thanks Kev (6 Replies)
Discussion started by: kev112
6 Replies

10. UNIX for Dummies Questions & Answers

trapping keys

how do i trap enter command entered by a user. actually i am throwing a screen this screen has no input but this screen should be displayes unless and until the user presses the enter key. as the user presses enter key the command prompt should come. how do i achieve this (1 Reply)
Discussion started by: sunil bajaj
1 Replies
Login or Register to Ask a Question
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)