Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  Downloads
    Scripts
      Korn
        Functions

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

getch

Korn Shell getch: Capture a single key press without requiring carriage return or enter key.

See visualSelect menu system for a full implementation of "getch" capturing function keys, arrow keys, and other cursor movement keys.



################################################################
####    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
####
####    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 [-q]
####
####                   -q = quiet mode, no output
####
####    AUTHOR: Dana French (dfrench@mtxia.com)
####
####
#### See http://www.mtxia.com/js/Downloads/Scripts/Korn/Functions/visualSelect/index.shtml
#### visualSelect menu system for a full implementation of "getch"
#### capturing function keys, arrow keys, and other cursor movement keys.
####
################################################################
function getch {
    typeset TMP_GETCH
    typeset STAT_GETCH="0"
    stty raw
    TMP_GETCH=`dd bs=1 count=1 2> /dev/null`
    STAT_GETCH="${?}"
    stty -raw

    if [[ "_${1}" != "_-q" ]]
    then
        print -r -- "${TMP_GETCH}"
    fi
    return ${STAT_GETCH}
}

-
Get a single Char
-
 


FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com