Preface: I have a server running on an old laptop. The screen is always on with a login prompt, but because its keyboard is in pretty bad shape, I use it exclusively via ssh. The screen is in a good position, though; I want to use it to display a clock and some stats about what my server is doing. I have scripts to display all those things, but I want to always show them on the monitor screen.
My question is, how do I get my script (called HUD) to run on /dev/tty1, instead of the login prompt. Hopefully, it should be possible to accept keyboard input as well as display its output, so that it can use the keyboard to show more info where needed in a future version. I'd also like tty2 etc. to remain active as login screens, in face I actually do need to login locally.
For a start, I tried creating a script that I can run from ssh to start the HUD. It goes something like this:
( flock -n 9 watch --interval 0.2 --precise --color --notitle --exec /path/to/script & disown ) 9> /var/lock/hud > /dev/tty1 2> /dev/tty1 < /dev/tty1
(I had to use
& disown instead of
nohup recognized the tty and redirects output to
This sort-of works. However, it has a few issues:
- It doesn't steal the terminal's keyboard input, so you can't ctrl+c to get out of it (nor change the script to actually use the keyboard input), and if you press enter it show it and scrolls the display, never refreshing it correctly afterwards.
- Oddly, if I disconnect the ssh session which created it, it stops working and shows a message:
exec: No such file or directory. If I reconnect to ssh, it resumes functioning properly.
- It feels hackish.
Is there a better way to do this? How?