Running a program on boot without login, using the screen

Posted by configurator on Ask Ubuntu See other posts from Ask Ubuntu or by configurator
Published on 2012-09-01T21:01:55Z Indexed on 2012/09/01 21:49 UTC
Read the original article Hit count: 257

Filed under:
|

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 because nohup recognized the tty and redirects output to nohup.out instead.)

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?

© Ask Ubuntu or respective owner

Related posts about tty

  • How to mount a blu-ray drive?

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    Maybe it is for the best to close this question. This has nothing to do with a bluray drive in general anymore. Probably a hardware defect. I will try to test it with a windows system and different cables again... Thx so far. I have a bluray/dvd/cdrom drive with SATA. Ubuntu wont find it under /dev/sd wodim… >>> More

  • Fedora, ssh and sudo

    as seen on Server Fault - Search for 'Server Fault'
    I have to run a script remotely on several Fedora machines through ssh. Since the script requires root priviliges, I do: $ ssh me@remost_host "sudo touch test_sudo" #just a simple example sudo: no tty present and no askpass program specified The remote machines are configured in such a way that… >>> More

  • TTY Resolution in Xubuntu 9.10

    as seen on Super User - Search for 'Super User'
    I've exhausted my ability to search through Google for this, so I'm giving it a go here. What I'm trying to do is increase the resolution (or decrease the font size) in the TTY terminals. Xubuntu 9.10 uses GRUB2, and everywhere I can find directs me to edit the /etc/default/grub File in order… >>> More

  • Bricked - tty mode incorrect, terminal disabled, unity broken

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    After installing VirtualBox unity seems to be uninstalled.. Launcher and task bar are missing. I can't access terminal from the normal ctrl alt T command. I tried logging into TTY mode but it says my login is incorrect. I am trying to login with my normal ubuntu username and password. I have searched… >>> More

  • Disk errors on tty and syslog/dmesg

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    Recently I have started to get a lot of these errors: Jun 18 08:57:42 abacus kernel: [ 401.554292] ata5: SError: { HostInt 10B8B } Jun 18 08:57:42 abacus kernel: [ 401.559346] sr 4:0:0:0: CDB: Test Unit Ready: 00 00 00 00 00 00 Jun 18 08:57:42 abacus kernel: [ 401.560191] ata5.00: cmd a0/00:00:00:00:00/00:00:00:00:00/a0… >>> More

Related posts about redirect