View Full Version : how can I change what a script does while it is running, by pressing a key
July 13th, 2010, 10:52 PM
I am trying to write code which will let the user press a key like 'b' and run an operation, while a script is still running, and have the script continue afterwards. How can I do this??? I am using Linux. working in python
July 13th, 2010, 11:05 PM
while read -p '> ' -r -n1; do
case $REPLY in
echo "b stuff..."
echo "Bye bye"
Read this to learn bash scripting: http://mywiki.wooledge.org/BashGuide
July 13th, 2010, 11:11 PM
can you please explain the code and how it works. im working in python.
July 13th, 2010, 11:36 PM
Well, it waits for a char from stdin and runs a set of commands based on what char it was...
Now that you specified you really meant a python script though, I don't see why that matters; a python script to do something similar will look completely different.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.