- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Exit loop with any keystroke
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
11-12-2003 05:15 AM
11-12-2003 05:15 AM
I have a simple script that enters into a continous loop and runs a program to dipslay the contents of a file to the screen. I know I can exit out of the loop by hitting Ctrl-C, etc.
What I would like to do is exit the loop when a user presses ANY key, not just return, or Ctrl-C, etc.
Is there a way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2003 05:49 AM
11-12-2003 05:49 AM
Re: Exit loop with any keystroke
stty raw;char=`dd if=/dev/tty count=1 2>/dev/null`;stty -raw
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2003 06:04 AM
11-12-2003 06:04 AM
Re: Exit loop with any keystroke
Only I seem to have to hit 3 keystrokes to get it to quit.
Might give you some ideas.
Basically save the stty settings, send a message, turn off echo and -icanon and then have dd wait for an input character then restore the old stty settings:
old_tty_setting=$(stty -g)
echo "Hit key to break loop "
stty -icanon -echo
usethis=$(dd bs=1 count=1 of=/dev/null)
stty $old_tty_setting
Hope that helps or maybe someone can suggest why it would take multiple characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2003 07:42 AM
11-12-2003 07:42 AM
Solutionhttp://www.dbaoncall.net/references/ex_one_char.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2003 01:26 AM
11-13-2003 01:26 AM