7

I've currently got 2 ttys logging in automatically, but I need to launch a node script from one and a C program from another as soon as the device loads.

The device is a Raspberry Pi running Raspbian. It's set up to function like an appliance, these two programs will run for a few hours at a time before the device is turned off.

I've successfully launched my programs via /etc/rc.local but it seems that this isn't the same as actually launching from tty, they are closed before the prompt loads.

2
  • 6
    Have you tried openvt myprogram? It should create a tty and run your command there. Dec 13, 2012 at 21:10
  • 1
    @donothingsuccessfully Thanks, this is what I needed!
    – thewebguy
    Dec 19, 2012 at 15:06

2 Answers 2

3

I think it's possible to start whatever you want from /etc/inittab

e.g. (/etc/inittab excerpt)

# TERMINALS
c1:12345:respawn:/sbin/agetty 38400 tty1 linux

# Launch top redirecting its output to tty2, without redirecting input
c2:2345:respawn:/usr/bin/top >/dev/tty2 2>&1

# Launch ascii-invaders with redirected input 
# (you will be able to control the game with keyboard after switching to tty3)
c3:2345:respawn:/usr/games/bin/ascii-invaders </dev/tty3 >/dev/tty3 2>&1
0

Depending on what you really need, launching form init script might indeed be better. You'd probably have to daemonize it somehow (e.g. by running it on background) though, otherwise the init system will wait until the programs finish. On the other hand, if you need to interact with the programs, running them with a controlling terminal is easier. You can combine both approaches by running it in tmux or screen from an init script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .