- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Keyboard reading from ksh
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
тАО02-09-2009 10:02 AM
тАО02-09-2009 10:02 AM
How to accept only the ENTER key in a ksh compatible script to provide something like that:
"Please do action ... and press ENTER"
any idea ?
Bests Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2009 10:20 AM
тАО02-09-2009 10:20 AM
Re: Keyboard reading from ksh
enjoy, life.
Jean-Pierre Huc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2009 11:19 AM
тАО02-09-2009 11:19 AM
Re: Keyboard reading from ksh
Here is an example. Change the script and it will still work.
#!/bin/bash
filename="/home/paul/myfile.tar.gz"
hostname="ftp.myhost.com"
username="username"
password="password"
ftp -un $hostname <
quote PASS $password
binary
put $filename
quit
EOF
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2009 01:19 PM
тАО02-09-2009 01:19 PM
Re: Keyboard reading from ksh
echo "Press ENTER to continue"
read
echo "Operation complete"
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2009 01:27 PM
тАО02-09-2009 01:27 PM
Re: Keyboard reading from ksh
If you want to distinguish the action of pressing the ENTER key alone, you could do:
# echo "press ENTER \c";read LINE;[ -z "${LINE}" ] && echo OK || echo "Please just press ENTER"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 07:39 AM
тАО02-11-2009 07:39 AM
Re: Keyboard reading from ksh
In fact, is there another keyboard function. (named readchar by example) I'd like to have only one striked key on input.
ENTER key was not the good example because source of confusion on my question. sorry.
Suppose you have choice between [Y]es or [N]o during execution script. If the user press Y or N it's enough to continue and ENTER is not necessary.
Is it possible ?
Thanks Guys and sorry again about the confusion.
Bests Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 06:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 09:22 PM
тАО02-11-2009 09:22 PM
Re: Keyboard reading from ksh
SAVstty=$(stty -g)
stty raw min 1 time 0
a="$(od -A n -c -N 1)
stty $SAVstty
echo $a
if you type a
if you type a ^J you will get \n
a backspace \b
a tab \t
.....
if you replace -c in od command by -x then you get the ascii value in hex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-12-2009 07:52 AM
тАО02-12-2009 07:52 AM
Re: Keyboard reading from ksh
The final way to solve this small affair is:
echo -n "Enter a character: " # prompt
/bin/stty -icanon && /bin/stty eol ^A
key=`dd if=/dev/tty bs=1 count=1 2>/dev/null` # read a key press
/bin/stty icanon && /bin/stty eol ^@
echo "$key" # echo newline and/or key -- OPTIONAL
Bests Regards
Den