问题原文
原帖链接 · Max Muster · CC BY-SA 4.0
OK lets admit you connect a display to a computer that runs linux.
The display will show a login screen asking for user and password.
I am logged in via SSH on pts/0
I can now run a program on TTY1 like this
some-program > /dev/tty1 2>&1
But what I am looking for is a possibility to just show my console to tty1 without the user to be able to interfere. I tried:
screen > /dev/tty1 2>&1
but it opened the screen on pts/1 instead ot tty1. I tried
top > /dev/tty1 2>&1
result was a dark screen any hint?
已采纳解答
原帖链接 · A.B · CC BY-SA 4.0
The openvt command, present in the kbd package on Debian, deals specifically with using VTs.
For example you can run top on /dev/tty8 with:
openvt -c 8 -- top
It takes care itself of preparing the correct detached environment for the forked command (redirecting I/Os to the VT, calling setsid(2) etc.) and returns immediately.
I avoided /dev/tty1 in this example because very often first /dev/ttyX are already used to spawn login prompts.
Use chvt (eg chvt 8) if you have to change the VT to be displayed.
You can also choose to not specify the VT and let openvt pick the first available, and immediately switch to it using -s, So this would work in one shot:
openvt -s -- top
Be careful to not leave older instances running then...
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
