How to do non-blocked I/O?

Dan_Jacobson at ATT.COM Dan_Jacobson at ATT.COM
Wed Jun 12 11:59:42 AEST 1991


>>>>> "Peter" == Peter Steele <peter at aucs.acadiau.ca> writes:

Peter> I want to modify our system startup scripts to ask a question like

Peter>     Okay to bring up databases (y/n)?

Peter> and if there is no reply within, say 5 seconds, assume "y". Can
Peter> I do this from sh or csh

Most major dudes [<- Steely Dan musical reference there] frown upon
csh, so that leaves sh.  This works in ksh & sh, so it probably works
in bash too (note SYS Vish "\c" for echo though... no big deal)

#just examples
program="screen -r || screen" #maybe set this in a case statement

test -n "$program" &&
	sec=8 &&
	trap 'trap 2' 2 &&
	echo "you got $sec seconds to interrupt before
		\"$program\"... \c" &&
	sleep $sec &&
	trap 2 &&
	eval $program



More information about the Comp.unix.shell mailing list