Sending keystroke through script.


I need help sending a keystroke from a shell script. My script telnets into a server's serial console. I have this part down. Then I need to send the keystroke combination "Esc+(" to redirect me to the server's iLo/BMC interface. (I need to simulate pressing the keystroke for opening parenthesis while the Escape key is depressed) I don't know how to send keystrokes from a simple linux script. I am not allowed to install any new packages and would really like to keep this as a script and not a c program. I don't need the script to 'expect' anything, just send the keystroke.

Who is Participating?
TintinConnect With a Mentor Commented:
You could try

(echo -e "\033(") | telnet server
Duncan RoeSoftware DeveloperCommented:
Is this in a GUI normally? X can detect arbitrary key press combinations, but there is no ASCII equivalent. If you touch the Escape key, you will get an Ec (033) character. If you hold it down, you may get many depending on your console settings: whether key repeat is on and what is the frequency. If in the meantime you press "(", you may get one, interspersed with the escapes.
In brief, you can't send key press events to a serial console.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.