Linux 更改为另一个 /dev/ttyX 并在那里运行程序

Mus*_*afa 3 linux sh tty

是否可以在 /dev/tty1 上运行脚本并生成一个在 /dev/tty2 上运行的程序并等待它完成并运行脚本中的其他命令?例如:

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
Run Code Online (Sandbox Code Playgroud)

myprogram.sh:

echo "Hello' this is from terminal 2, please type your input:"
read A
exit A
Run Code Online (Sandbox Code Playgroud)

Igo*_*bin 5

是的,您可以使用 来做到这一点openvt

openvt -c 2 sh myprogram.sh
Run Code Online (Sandbox Code Playgroud)