What is a command-line equivalent of pressing a key on remote computer via ssh

1

2

What are the options to target specific keys on a remote computer and execute the equivalent of virtually pressing them from the terminal via ssh (what would normally be a user pressing them)?

Example is adjusting the volume:

sudo osascript -e "set Volume 10"

I'm not asking for applescript.

les

Posted 2014-01-30T01:23:44.160

Reputation: 121

Answers

2

There is some information about how to do that HERE. An excerpt from that page is included below.

Terminals only understand characters, not keys. So al function keys are encoded as sequences of characters, using control characters. Apart from a few common ones that have an associated control character (Tab is Ctrl+I, Enter is Ctrl+M, Esc is Ctrl+[), function keys send escape sequences, beginning with Ctrl+[ [ or Ctrl+[ O. You can use the tput command to see what escape sequence applications expect for each function key on your terminal.

Also, Hacker's Keyboard was suggested on the page linked above, if you are attempting to do the same sort of thing from an Android device.

joeeey

Posted 2014-01-30T01:23:44.160

Reputation: 1 396

0

You can run commands over ssh directly.
ssh user@host1 command will run the command on host1 under the user.
So to use your set volume example, you could do this -
ssh root@host1 osascript -e "set Volume 10"

Lawrence

Posted 2014-01-30T01:23:44.160

Reputation: 3 807