0

I have a machine which is hooked up to a physical display and to which I have ssh & root access, but which does not have a mouse or keyboard. It does not have X installed. I would like to run some commands such that their output is displayed on the physical display.

My thought was that I should just write to /dev/tty1, as I only needed to send keypresses, not receive data. And it worked - kind of. The display is sitting at the login prompt, so running

echo "myusername" | sudo tee /dev/tty1

does in fact cause my username to fill in the field in the physical display! But it never goes to the password prompt...sending newlines does not seem to be the same as a physical press of the enter key. I have tried

echo -ne "\n" | sudo tee /dev/tty1
echo -ne "\r\n" | sudo tee /dev/tty1
echo -ne "\0" | sudo tee /dev/tty1

All just seem to add more blank lines to the username field. Is there a trick?

matoro
  • 3

1 Answers1

0

Have you considered using a terminal multiplexer like screen or tmux instead? You get the added benefit of keeping your session alive after you log out as well.

On the machine hooked up to the monitor:

sudo apt install screen

To start a session, use:

screen -S nameOfSession

To attach to the session, use:

screen -r nameOfSession
jjj
  • 111
  • Yes, but you would still need a keyboard plugged in to attach to the session on the physical side. That said the C code in the linked answer did not work but the python code here did: https://unix.stackexchange.com/a/345572/258915 so I will mark this as a dupe. See also here: https://stackoverflow.com/a/29616465/6214870 – matoro Jun 12 '19 at 21:58