I have a program that takes input from the keyboard and presents a nice visualization. The purpose of the program is so that my infant can mash on the keyboard and get the computer to do something.
However, I would like to write a keyboard input sanitizer that is disjoint from the main program. Conceptually, I would want the program have the functionality:
sanitize_keyboard_input | my_program
Where my_program
thinks it is getting input from the keyboard but it is really getting input from sanitize_keyboard_input
. Is there a way to do this? I am running Ubuntu linux if that helps.
Best Answer
I wrote this a long time ago. It's a script that sits between the user's input and an interactive program, and allows the input to be intercepted. I used it to escape to the shell to check filenames when running old Fortran programs that asked lots of questions. You could easily modify it to intercept particular inputs and sanitize them.
A simple example test program you can try it out on: