- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell scripting
Operating System - HP-UX
1823077
Members
3206
Online
109645
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2003 03:50 AM
тАО10-13-2003 03:50 AM
Shell scripting
Experts,
I dont know whether this is the right place i should put this RFH (Request For Help). I am executing a netbackup command which can throw three different error codes a 0,1 and 134. I have to handle these error codes in different manner. Let me put down the process how everything goes.
step -1 : script executes putting a flag called "backupstart" with time in a
text file..
Step-2: Execute the backup...list of file systems should be taken from another text file as input. basically we should be able to edit the text file at will for whatever file system we want to backup.
Step-3: Needs to be pretty smart in finding the exit code of step-3 and take corrective action
Following are the corrective actions
If ( "backupstart" flag exists && exit code == 134 ) Do nothing
else if ("backupstart" flag exists && exit code == 0) execute another script sample.sh
and remove the "backupstart" flag
else if (status == 1 && backupstart flag exists) e-mail/page support staff "someemail.email.com"
Experts first i dont know how to put a flag before starting the execution of the script as said in step-1.
I have the script for step-2. I dont know how to work handle the error codes for the and do something after that in Step-3.
I am attaching the script i have for step-2. If you can help me in getting step-1 and step-3 i would be grateful to you.
I dont know whether this is the right place i should put this RFH (Request For Help). I am executing a netbackup command which can throw three different error codes a 0,1 and 134. I have to handle these error codes in different manner. Let me put down the process how everything goes.
step -1 : script executes putting a flag called "backupstart" with time in a
text file..
Step-2: Execute the backup...list of file systems should be taken from another text file as input. basically we should be able to edit the text file at will for whatever file system we want to backup.
Step-3: Needs to be pretty smart in finding the exit code of step-3 and take corrective action
Following are the corrective actions
If ( "backupstart" flag exists && exit code == 134 ) Do nothing
else if ("backupstart" flag exists && exit code == 0) execute another script sample.sh
and remove the "backupstart" flag
else if (status == 1 && backupstart flag exists) e-mail/page support staff "someemail.email.com"
Experts first i dont know how to put a flag before starting the execution of the script as said in step-1.
I have the script for step-2. I dont know how to work handle the error codes for the and do something after that in Step-3.
I am attaching the script i have for step-2. If you can help me in getting step-1 and step-3 i would be grateful to you.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2003 04:07 AM
тАО10-13-2003 04:07 AM
Re: Shell scripting
standard error trapping script logic.
/usr/openv/netbackup/backupscript
rc=$?
if [ $rc -eq 134 ] then
# take action based on code 134 email whatever
fi
# action
if [ $rc -eq 0 ] then
# take action based on code 134 email
sample.sh
fi
A little more elegant:
if [ $rc -nq 0 ] then
# action perhaps check the code and act.
else
#
sample.sh
fi
Thats how you trap and act on error codes.
I see no reason to make it really complex.
SEP
/usr/openv/netbackup/backupscript
rc=$?
if [ $rc -eq 134 ] then
# take action based on code 134 email whatever
fi
# action
if [ $rc -eq 0 ] then
# take action based on code 134 email
sample.sh
fi
A little more elegant:
if [ $rc -nq 0 ] then
# action perhaps check the code and act.
else
#
sample.sh
fi
Thats how you trap and act on error codes.
I see no reason to make it really complex.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2003 06:02 AM
тАО10-13-2003 06:02 AM
Re: Shell scripting
Ramesh -
Below is a cut and paste from one of our netbackup scripts. It is pretty much what you are asking though our return code searches are different. Hope the lines "line up" on the paste to the reply.
Best of Luck.
Regards,
dl
# =================================================================================================
# Start the backup process.
# Create a touch file for verification of completed backup if successful.
# =================================================================================================
date > $ERROR_LOG1
$veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1
status=$?
if [ "$status" -eq 0 ]
then
echo "Backup results for $CLASS $FILE_LIST_1 return code $status" >> $RESULTS_FILE
touch $COMPLETED_FILE1
# =================================================================================================
# Call the call_umount script if all backups finished successfully.
# =================================================================================================
$CALL_UMOUNT
exit 0
fi
while [ "$status" -gt 0 ]
do
if [ "$status" -eq 84 -a "$count" -eq 0 ]
then
echo "Backup results for $CLASS $FILE_LIST_1 return code $status" >> $RESULTS_FILE
echo "Restarting this job at `date`" >> $RESULTS_FILE
$veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1
status=$?
let count="$count + 1"
elif [ "$status" -ne 84 -a "$status" -ne 0 ]
then
echo "Errors on backup for $CLASS return code $status" >> $ERROR_LOG1
echo "Contact Ron or Dave." >> $ERROR_LOG1
echo "Process affected is jdaprod backup." >> $ERROR_LOG1
echo "No completed flag will be created; umount will not occur." >> $ERROR_LOG1
$mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST < $ERROR_LOG1
$VSE_NOTIFY
exit;
elif [ "$count" -eq 1 -a "status" -ne 0 ]
then
echo "Errors on backup for $CLASS return code $status" >> $ERROR_LOG1
echo "Contact Ron or Dave." >> $ERROR_LOG1
echo "Process affected is jdaprod backup." >> $ERROR_LOG1
echo "No completed flag will be created; umount will not occur." >> $ERROR_LOG1
$mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST < $ERROR_LOG1
$VSE_NOTIFY
exit;
fi
done
Below is a cut and paste from one of our netbackup scripts. It is pretty much what you are asking though our return code searches are different. Hope the lines "line up" on the paste to the reply.
Best of Luck.
Regards,
dl
# =================================================================================================
# Start the backup process.
# Create a touch file for verification of completed backup if successful.
# =================================================================================================
date > $ERROR_LOG1
$veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1
status=$?
if [ "$status" -eq 0 ]
then
echo "Backup results for $CLASS $FILE_LIST_1 return code $status" >> $RESULTS_FILE
touch $COMPLETED_FILE1
# =================================================================================================
# Call the call_umount script if all backups finished successfully.
# =================================================================================================
$CALL_UMOUNT
exit 0
fi
while [ "$status" -gt 0 ]
do
if [ "$status" -eq 84 -a "$count" -eq 0 ]
then
echo "Backup results for $CLASS $FILE_LIST_1 return code $status" >> $RESULTS_FILE
echo "Restarting this job at `date`" >> $RESULTS_FILE
$veritas_path/bpbackup -w -c $CLASS -s $SCHED -f $FILE_LIST_1
status=$?
let count="$count + 1"
elif [ "$status" -ne 84 -a "$status" -ne 0 ]
then
echo "Errors on backup for $CLASS return code $status" >> $ERROR_LOG1
echo "Contact Ron or Dave." >> $ERROR_LOG1
echo "Process affected is jdaprod backup." >> $ERROR_LOG1
echo "No completed flag will be created; umount will not occur." >> $ERROR_LOG1
$mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST < $ERROR_LOG1
$VSE_NOTIFY
exit;
elif [ "$count" -eq 1 -a "status" -ne 0 ]
then
echo "Errors on backup for $CLASS return code $status" >> $ERROR_LOG1
echo "Contact Ron or Dave." >> $ERROR_LOG1
echo "Process affected is jdaprod backup." >> $ERROR_LOG1
echo "No completed flag will be created; umount will not occur." >> $ERROR_LOG1
$mail_path/mailx -s "Errors on backup of $CLASS Directory" $MAIL_LIST < $ERROR_LOG1
$VSE_NOTIFY
exit;
fi
done
"I'm not dumb. I just have a command of thoroughly useless information."
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP