- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- ctrl-d in while statement
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
Discussions
Discussions
Forums
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
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
тАО03-01-2006 08:16 AM
тАО03-01-2006 08:16 AM
thank YOU
Solved! Go to Solution.
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2006 08:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2006 08:23 AM
тАО03-01-2006 08:23 AM
Re: ctrl-d in while statement
thank YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2006 08:34 AM
тАО03-01-2006 08:34 AM
Re: ctrl-d in while statement
Having said that, you can do this:
char=""
while [[ $char -ne "^D" ]]
do
.
.
.
stty raw;char=`dd if=/dev/tty count=1 2>/dev/null`;stty -raw
done
and that may work for you.
mark
- Tags:
- stty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2006 08:46 AM
тАО03-01-2006 08:46 AM
Re: ctrl-d in while statement
I agree with Mark.
Control chars can be problematic - especially for ttytype issues - even sessions themselves.
It's better to use standard alpha ASCII chars like "Q/q" for quit, "E/e" for exit, etc. Even whole words like quit or exit.
These are easily programable with case statements.
My $0.02,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2006 09:24 AM
тАО03-01-2006 09:24 AM
Re: ctrl-d in while statement
while read LINE
do
if [ -z "$LINE" ]
then
echo "User entered nothing, exiting..."
exit
fi
...process other $LINE contents...
done
Be sure to quote "$LINE" to properly handle a null input.
Bill Hassell, sysadmin