Search code examples
linuxshtty

Linux change to another /dev/ttyX and run program there


Is it possible to run a script on /dev/tty1 and spawn a program to run on /dev/tty2 and wait for it to complete and run the other commands in the script? For instance:

echo "Hello, this is from terminal 1"
chvt 2
sh myprogram.sh (I want it to run on tty2, but it runs on tty1)
chvt 1

myprogram.sh:

echo "Hello' this is from terminal 2, please type your input:"
read A
exit A

Solution

  • Yes, you can do this using openvt.

    openvt -c 2 sh myprogram.sh