- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to set time-outs for commands in a script
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
04-18-2007 08:51 PM
04-18-2007 08:51 PM
Sometimes I need to set a time-out for a command line in a critical script.
is there any trick to achieve that ?
Solved! Go to Solution.
- Tags:
- timeout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2007 08:54 PM
04-18-2007 08:54 PM
Re: how to set time-outs for commands in a script
check "man sleep" and "man wait"
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2007 09:31 PM
04-18-2007 09:31 PM
Re: how to set time-outs for commands in a script
sleep would simply block the execution of the next command for the number of seconds passed to sleep, while wait would block until all backgrounded, or that whose PID was passed to wait, have finished.
In Perl scripts one usually sets up a signal handler for SIGALRM (at least one could do this with a shell trap) in an eval block and triggers the alarm() syscall.
I wonder if the shell offers a similar scriptable solution, or if one would have to resort to a C or Perl "plugin"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2007 11:50 PM
04-18-2007 11:50 PM
Re: how to set time-outs for commands in a script
In a shell script you can use 'line -t' like:
# REPLY=`line -t 10`
# [ -z "${REPLY}" ] && echo "You didn't enter anything!"
The argument to '-t' is an integer number of seconds to wait on a read of data before timing out.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 01:40 AM
04-19-2007 01:40 AM
Re: how to set time-outs for commands in a script
There are always many details to be worked
out, but did you mean something like this?
urtx> cat ./trap_test.sh
#!/bin/sh
# Establish a no-op SIGCHLD handler.
trap ":" 20
# Display date-time, and set the timer.
date
sleep 10 &
# Begin the time-uncertain command sequence.
echo 'question? \c'
read ans
echo "ans: >${ans}<"
# Display date-time after the time-uncertain command sequence.
date
urtx> ./trap_test.sh
Thu Apr 19 08:36:39 CDT 2007
question? a
ans: >a<
Thu Apr 19 08:36:40 CDT 2007
urtx> ./trap_test.sh
Thu Apr 19 08:36:50 CDT 2007
question?
ans: ><
Thu Apr 19 08:37:00 CDT 2007
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2007 08:17 AM
04-25-2007 08:17 AM
Re: how to set time-outs for commands in a script
Ping. Perhaps you will evaluate the latest responses.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2007 10:08 AM
04-25-2007 10:08 AM
SolutionBill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 11:20 AM
10-14-2008 11:20 AM