HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to make a script like "press any key within 10...
Operating System - HP-UX
1833188
Members
2868
Online
110051
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
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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-15-2004 02:16 PM
10-15-2004 02:16 PM
I want to make a script, it will wait user's input, if exceed 10 seconds and user input nothing , the script will go-on with a default value!
How to do?
Thanks a lot and very sorry for my poor English!
How to do?
Thanks a lot and very sorry for my poor English!
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2004 02:45 PM
10-15-2004 02:45 PM
Solution
Hi,
Take a look at the 'line' command. You can use the -t option to specify a timeout value in seconds. Here is a snippet from the man page:
The following lines in a shell script prompt for a file name and display information about the file:
echo 'Enter file name: \c'
reply=`line`
ls -l $reply
To limit the response time to 10 seconds, use the form:
reply=`line -t 10`
then test for no response. If no response occurs before timeout expires, a default behavior should be provided.
So all you would need to do is add an 'if' statement to test the variable and set a default value if it doesn't have a value.
JP
Take a look at the 'line' command. You can use the -t option to specify a timeout value in seconds. Here is a snippet from the man page:
The following lines in a shell script prompt for a file name and display information about the file:
echo 'Enter file name: \c'
reply=`line`
ls -l $reply
To limit the response time to 10 seconds, use the form:
reply=`line -t 10`
then test for no response. If no response occurs before timeout expires, a default behavior should be provided.
So all you would need to do is add an 'if' statement to test the variable and set a default value if it doesn't have a value.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 08:50 AM
10-18-2004 08:50 AM
Re: How to make a script like "press any key within 10 seconds"?
Hi,
Keep in mind that this 'line' command only works with sh and ksh. It will not work with csh.
Regards,
Mark
Keep in mind that this 'line' command only works with sh and ksh. It will not work with csh.
Regards,
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 09:00 AM
10-18-2004 09:00 AM
Re: How to make a script like "press any key within 10 seconds"?
It works fine with csh also, as far as I can tell (of course, you have to use slightly different syntax):
#!/bin/csh
set line=`line -t 2`
echo $line
#!/bin/csh
set line=`line -t 2`
echo $line
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
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP