Search code examples
linuxinitramfs

<Not solved yet> How can I run a program on a tty?


I need tty interactive on onboot of linuxkit.

Now, setsid -w agetty -a root -L 38400 ttyS0 vt100 is working. But I want to run a specific program. Is there a way?


Thanks to "Mahdy Mirzade" for reply,

$ setsid sh -c 'exec ls <> /dev/tty2 >&0 2>&1'

This works pretty well, but It can't control the tty.

$ setsid sh -c 'exec sh -c "echo hello > /dev/tty" <> /dev/tty10>&0 2>&1'

(error message) cannot create /dev/tty: Inappropriate ioctl for device

Therefore, it is impossible to operate a program that receives user input through tty. Is there any way to solve this?


Solution

  • Try passing sh -c to your command:

    $ setsid sh -c 'exec ls <> /dev/tty2 >&0 2>&1'