Monday, January 7, 2008

getche() equivalent in Linux

]# echo -n "Press any key to continue..." && read -n 1
or
]# read -sn1 -p " Press any key to continue "
Also :
]$ echo -n "Press any key to continue..." && /sbin/getkey


##test.sh
if /sbin/getkey -i -c 5 -m "Press Y within %d sec to continue " y;
then
echo You pressed y
else
echo You pressed Wrong
fi
echo

/sbin/getkey i && touch /var/run/confirm
if pressed key is 'i' return 1 else 0.
&& fail if 0 .

http://www.webservertalk.com/archive200-2005-7-1138374.html

No comments: