Sunday, December 16, 2007

"pause" in shell script


Apart from using "sleep", here something you can do with BASH to pause something until user responds!

$ cat pause.sh
f_pause()
{
key=""
echo -n "Press any key to continue.."
stty -icanon
key=`dd count=1 2>/dev/null`
stty icanon
}

echo "I am here"
f_pause
echo "I am at the end"

Another way :

$ cat pause1.sh
f_pause(){
read -p "$*"
}

echo "I am here"
f_pause "Hit Enter key to continue."
echo "I am in the last line"

No comments:

© Jadu Saikia www.UNIXCL.com