I have a script in which I'm trying to add the functionality of exiting upon keypress. Thus far, my code looks like what you see below:
keyinput='' if [ -t 0 ]; then stty -echo -icanon -icrnl time 0 min 0; fi while [ "x$keyinput" = "x" ]; do echo "Press Any Key to Exit." echo "Users currently logged on:" w #Display who is currently logged on echo "Disk space utilization:" df -h #Display disk space utilization in human readable form echo "Memory and CPU Utilization:" ps axo user,pmem,pcpu #Display Username, % of Memory Used, CPU Usage % keyinput="`cat -v`" done if [ -t 0 ]; then stty sane; fi echo "Thanks for using the Live Monitor, you pressed '$keyinput' to exit."
For some odd reason, I can not get the exit on any key input to work.