- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Exit Script on failure?
Categories
Company
Local Language
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
Discussions
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
Community
Resources
Forums
Blogs
- 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
06-21-2005 10:31 PM
06-21-2005 10:31 PM
I have written sub script that sends (rcp's) a certain type of file to another server. If by any chance the line drops however this file will be put into an archive dir resulting in the file not being sent. Can anyone tell me how I can incorporate a err/exit code into my script so that if the rcp fails then the entire script will exit at that point peventing the file being archived and ensuring that it will get rcp'ed the next time it is run from the cron.
Dermot
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 10:33 PM
06-21-2005 10:33 PM
Re: Exit Script on failure?
Can you attach the script & the cron entry which is doing this?
Regards,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 10:39 PM
06-21-2005 10:39 PM
Re: Exit Script on failure?
This sub script is called as part of a larger script that is kicked off the cron every 5 mins.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 10:42 PM
06-21-2005 10:42 PM
Re: Exit Script on failure?
Could not open the attachment. Please reattach.
Regards,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 10:44 PM
06-21-2005 10:44 PM
Re: Exit Script on failure?
This should work :
.....
rcp ....
var1=`echo $?`
if [ $var1 -ne 0 ]
then
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 10:47 PM
06-21-2005 10:47 PM
Re: Exit Script on failure?
rcp
if [[ $? -eq 0 ]]
then
echo "success"
...action..
else
echo "failure"
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 11:15 PM
06-21-2005 11:15 PM
Re: Exit Script on failure?
I really need to know how to transfer an error message from one script (this sub script) to another script (my main script).
Dermot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 11:32 PM
06-21-2005 11:32 PM
Solution#!/bin/ksh
# subscript.ksh
rcp
if [[ $? -eq 0 ]]
then
echo "Success"
else
echo "failure"
exit 1
fi
exit 0
######################
#!/bin/ksh
#main.ksh
sh subscript.sh
if [[ $? -eq 0 ]]
then
echo "Subscript is successful"
else
echo "Subscript is failed"
exit 1
fi
exit 0
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 11:36 PM
06-21-2005 11:36 PM
Re: Exit Script on failure?
#!/bin/ksh
#subscript.ksh
LOGFILE=/tmp/subscript.log
rcp ..
if [[ $? -eq 0 ]]
then
echo "success" > $LOGFILE
else
echo "failed" > $LOGFILE
fi
## Main script ###
#!/bin/ksh
#main.ksh
LOGFILE=/tmp/subscript.log
ksh subscript.ksh
if [[ -f $LOGFILE ]]
then
grep -q success $LOGFILE
if [[ $? -eq 0 ]]
then
echo "Subscript execution is success"
else
echo " ...failed"
fi
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2005 11:46 PM
06-21-2005 11:46 PM
Re: Exit Script on failure?
Kind Regards,
Dermot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2005 02:51 AM
06-22-2005 02:51 AM
Re: Exit Script on failure?
As it turns out the above solution is only half the solution as it does not completely solve my problem. In the instance where there are no files to rcp, the script returns an error value of 1 thus bombing out instead of returning value zero and continuing to the next sub script.
Is there a way I can catalog the dir, i.e. run a 'ls' or 'read' on the dir and if there are no files present simply return a 0 and continue with the remainder of the script instead of exiting?
Dermot