- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script hangs on error
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
02-12-2009 08:17 PM
02-12-2009 08:17 PM
Script hangs on error
I have a script which i execute. The command i execute in this scripts needs a user response "press any key", if it faces any problem and script hangs there. I want my script not to hang and continue untill the last command of script. Can anyone help me how to solve this?
Another thing is, on my one server i see a cron job as follows
/hotbackup.sh > g/hotbackup.log 2>&1
I want to know only the meangs of "2>&1" at the end of this command.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2009 08:29 PM
02-12-2009 08:29 PM
Re: Script hangs on error
You can redirect stdin to /dev/null for that step. Or use yes(1):
yes | command ...
>/hotbackup.sh > g/hotbackup.log 2>&1
>I want to know only the meaning of "2>&1"
This says redirect stdout to that file, then also redirect stderr to the (new) value of stdout.
You had the equivalent to: 1> file 2>&1
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2009 08:50 PM
02-12-2009 08:50 PM
Re: Script hangs on error
Thanks for the help.
Actually the command which fails also returns an output which i want to see and thats why i can't use > /dev/null. So i also want to see the output of command and i also doesn't want it to wait for the input. I cam calling it as follows.
./system_backup.sh > /scripts/sys_backup_out.log
and sys_backup_out.log is my output file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2009 08:58 PM
02-12-2009 08:58 PM
Re: Script hangs on error
let me explain a bot more, my this scrit runs some backup command on tape, if tape is not present, it hangs and asks to press any key. Even if i use "yes" as yuo told me in previous post, it again asks same question untell tape is ready. My intention is that if tape is not ready, it should not hang there and should come to the bottom and at the bottom, send me an email what ever the output of script is so that by checking email i can know whether backup was successfull or not. If i see error message in the email, i would insert the tape to take the backup. But if during script run if tape is not there, script is waiting and waiting and waiting and not exitig.
Thanks
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2009 09:46 PM
02-12-2009 09:46 PM
Re: Script hangs on error
I said stdin but this doesn't solve your next request. < /dev/null
>it should not hang there and should come to the bottom and at the bottom, send me an email
This is a problem. It has to hang there. But you could have another process that looks at the log file and possibly ps(1) and checks for that "press any key" and send you mail.
And then you have to figure out how to press that key.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2009 11:26 PM
02-12-2009 11:26 PM
Re: Script hangs on error
I didnt understand this
You had the equivalent to: 1> file 2>&1
In my example, where should i look for the errors. Can you please explan a bit more.
thanks in advance
Salman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2009 01:06 AM
02-13-2009 01:06 AM
Re: Script hangs on error
Basically you are redirecting both stdout AND stderr to g/hotbackup.log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2009 11:35 AM
02-16-2009 11:35 AM
Re: Script hangs on error
that's going to be a problem, as it's not "hanging" there, its looping waiting for a response and a tape. my initial thought was to stick the process (with the error redirected) might allow you to see the error, if its no stuck in the buffer, but won't allow you to "answer" the prompt when you do get a tape inserted.
perhaps you could check the status of the tape drive with "mt -f /dev/rmt/???" before you execute whatever backup command you are running. if the tape isn't inserted / available, send your email and fail the remainder of the job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2009 01:15 PM
02-17-2009 01:15 PM
Re: Script hangs on error
When a command is run, it may need input and it will also have standard output (stdout) and error output (stderr)
"cmd > log" this will send standard output to log. If you add "2>&1" aswell, this will also send the error output to the log.
Hope this explains a little better?