get character without waiting

Ron Nash nash at ucselx.sdsu.edu
Wed Jun 19 02:41:44 AEST 1991


mouse at thunder.mcrcim.mcgill.edu (der Mouse) writes:

>In article <1991Jun12.001056.24021 at watdragon.waterloo.edu>, nkkwan at crocus.uwaterloo.ca writes:

>> How can I check whether there is character waiting in standard input
>> or not?

>The only real answer is "there is no portable way".  Depending on
>precisely what you mean by "standard input", there may be a
>not-horribly-nonportable way.

A while back, in comp.sources.misc, Dan Smith posted a routine named
"grabchars" that does this for Sun's and BSD systems.  Email me if you
want a copy.  Here is a brief description:

} v05i073: grabchars 1.3, get/filter keystrokes directly from user (BSD)

}         "grabchars" gets one or more keystrokes from the user, without
} requiring them to hit return.  It was written to make shell scripts
} (doesn't matter what type) more interactive.
...
}         Enjoy, and send me your comments/suggestions.  2.0 will provide
} SYS V support.


-- 
Ron Nash 	San Diego State University
Internet:  	nash at ucselx.sdsu.edu
Gin-N-Tonic	5 year old 1/2 Arab endurance prospect
Luv on Fire	8 year old Arab, trusty steed and friend



More information about the Comp.unix.programmer mailing list