The following is the famous python code for checkin hitting of keyboard.
Code: Select all
import sys, select
print "You have ten seconds to answer!"
i, o, e = select.select( [sys.stdin], [], [], 10 )
if (i):
print "You said", sys.stdin.readline().strip()
else:
print "You said nothing!"Then, by typing in the command line, the code above run correctly with 10 seconds of timeout.
But if I start the code automatically at the boot up by using bash file associated with rc.local.
It always pass to "print "You said", sys.stdin.readline().strip()" without waiting of timeout !!!.
I tested it many time, It looks like there is some thing in i.
I did sys.stdin.flush() or read once before i, o, e = select.select( [sys.stdin], [], [], 10 )
but it does not work. There is something in i and no wait of timeout.
Later, if I manually run, the code run correctly as expected.
Thank you for your help.
Keattisak.