I am trying a way to check for keyboard input during an interactive telnet session on a connectport X so basically i go:
#> py myscript.py
I can ask for user input with the following code (this works):
command = "" console = code.InteractiveConsole() while command != "exit": command = console.raw_input("what do you want (or type “exit” to quit) $ ") command = command.strip() handle_command(command)
my problem is console.raw_input() is blocking, which i do not want.
the normal “Python” way of solving is by using the select function on stdio:
rlist, _, _ = select([sys.stdin], , , timeout) if rlist: s = sys.stdin.readline() print s else: print "No input. Moving on..."
but unfortunately when i try this Python on the CPX gives me an exception telling me sys.stdin has no method “fileno”
Is there a way to solve this problem?