Linux – How to Inject Keystrokes via a Shell Script

inputkeyboardlinuxshell-script

I'm trying to inject keystrokes into the input daemon so as to simulate typing from a Bash script. Is this possible, and if so, how can I make it happen?

Best Answer

If you are operating at the X level (as in Gilles' question), then use xdotool like so:

xdotool key KEYSTROKE_SPECIFIER

Where KEYSTROKE_SPECIFIER can be something like "a" or "F2" or "control+j"

EDIT: I missed your response to Gilles' question, sorry. I'll leave this response here as a solution for the X-case.

Related Question