I am currently working on a project where I am using a Raspberry Pi (running Raspian Wheezy) to handle authentication to a locked door. I have a usb numeric keyboard plugged into my pi, and I have written a script such that takes in keystroke data and processes it. This is basically how the script works:

while True:

    passcode = input()
    if passcode != 0: #It's never going to have a value of zero

         "Perform authentication with the passcode and unlock the door accordingly"

How can I set this up on my pi so that it starts handling the numeric keystroke input automatically on startup. I have tried putting python /directory/to/lockScript.py at the end of /etc/rc.local before the exit 0 line, and it appears that it does indeed run the script. Upon startup, if I open the task manager, I see that python is listed among the active processes. Also, I can see my script running listed in the output when I use ps aux | less in the terminal. However, the script is running in the background, and I'm fairly certain that it isn't picking up any keystrokes.

Does anybody know how to make my script run on startup in such a manner that it is able to read keystrokes from the background? As a matter of fact, I wouldn't care if it was even made the active window since there won't be a monitor attached to it.

Would there be a better way to go about this task than using input()?

Please forgive my ignorance, and thanks for checking out my question!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.