kshWeb |
getch Get a single character |
|
  |
Business Card File Data Entry System |
Korn Shell Books |
Free E-mail
YourName@ UnixGuru.zzn.com YourName@ UnixWizard.zzn.com YourName@ MCSE.zzn.com ... and many others!!! |
Cut and paste the following script into a file called "getch.ksh" on your system. Or click on getch.ksh to download a file containing the function.
#!/bin/ksh ################################################################ #### Korn Shell function to read one character from #### standard input (STDIN) without requiring a carriage #### return. This function would typically be used in a #### shell script to detect a key press. #### #### Load this file into your current environment as follows: #### #### . ./getch.sh #### #### Thats "dot-space-dot-slash-getch-dot-sh" #### #### You will then be able to issue the command "getch" #### from your current environment to retrieve one character. #### #### SYNTAX: getch [quiet] #### #### quiet = no output #### #### #### AUTHOR: Dana French #### EMAIL: dfrench@mtxia.com #### ################################################################ getch() { STAT_GETCH="0" stty raw TMP_GETCH=`dd bs=1 count=1 2> /dev/null` STAT_GETCH="${?}" stty -raw if [[ "_${1}" != "_quiet" ]] then print "${TMP_GETCH}" fi return ${STAT_GETCH} } ################################################################
  |
|
Business Card File Data Entry System |
Korn Shell Books |
Free E-mail
YourName@ UnixGuru.zzn.com YourName@ UnixWizard.zzn.com YourName@ MCSE.zzn.com ... and many others!!! |
For Information regarding this page, contact Dana French ( dfrench@mtxia.com )