Linux 屏幕无法打开您的终端 '/dev/pts/0' - 请检查
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21328140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
screen Cannot open your terminal '/dev/pts/0' - please check
提问by Fabian Harmsen
I want to start a program in a screen as the user "XYZ" with a script. This is my script in short form:
我想在屏幕中以用户“XYZ”的身份使用脚本启动一个程序。这是我的简短脚本:
# replace <newuser> with the user you wish to run teamspeak 3 with.
USER="teamspeak"
# Do not change this path
PATH=/bin:/usr/bin:/sbin:/usr/sbin
# The path to the teamspeak 3 server/scripts . example = /home/teamspeak3/teamspeak3-server
DIR=/home/teamspeak/voiceserver/teamspeak3
DAEMON=$DIR/ts3server_startscript.sh
# Change all PARAMS to your needs. I required the ini so teamspeak used MySQL
PARAMS="inifile=ts3server.ini"
#Name = The screen will be named from this.
NAME=teamspeak3
DESC="Teamspeak Server 3"
case "" in
start)
echo "Starting $DESC"
script -q -c "su $USER -l -c \"screen -m -d -S $NAME $DAEMON start\"" /dev/null
;;
stop)
su $USER -l -c "screen -S $NAME -X quit "
echo " ... done. $DESC Stopped."
;;
restart)
su $USER -l -c "screen -S $NAME -X quit "
echo " Closed Process, Restarting"
script -q -c "su $USER -l -c \"screen -m -d -S $NAME $DAEMON start\"" /dev/null
echo " ... done. $DESC Restarted"
;;
status)
# Check whether there's a "Team Speak 3" process
ps aux | grep -v grep | grep ts3server_ > /dev/null
CHECK=$?
[ $CHECK -eq 0 ] && echo "$DESC is UP" || echo "$DESC is DOWN"
;;
*)
echo "Usage: Cannot open your terminal '/dev/pts/0' - please check.
{start|stop|status|restart}"
exit 1
;;
esac
exit 0
I want connect in the screen, but I got this.
我想在屏幕上连接,但我得到了这个。
script -q -c "su $USER -l -c \"screen -m -d -S $NAME $DAEMON start\"" /dev/null
Did I do something wrong?
我做错什么了吗?
采纳答案by Nerrve
This happens because you may have done a sudo su user_name
and then fired the screen command.
发生这种情况是因为您可能已经执行了 asudo su user_name
然后触发了 screen 命令。
There are 2 ways to fix this.
有 2 种方法可以解决此问题。
- Login directly to "user_name" via ssh.
- Take ownership of the shell
by typing
script /dev/null
as the useruser_name
and then typescreen
- 通过 ssh 直接登录到“user_name”。
- 通过
script /dev/null
以用户身份键入user_name
然后键入 来获取 shell 的所有权screen
回答by Igor Chubin
To solve the problem try running script /dev/null
as the user you su
to before launching screen
.
要解决此问题,请在启动前尝试script /dev/null
以您的用户身份运行。su
screen
#script /dev/null
More on it:
更多相关信息:
回答by Javeed Shakeel
Run this command to own the shell
运行此命令以拥有 shell
#screen -r < name of the screen >
and try Screen
并尝试屏幕
sscreen(){
script -q -c "screen $*" /dev/null;
}
回答by Fabian Harmsen
here is the way i found.
i cann't use screen
from rc.localor better if i want to use it i would need root. I don't want to use root. My way is now to use crontab -e
this is working.
这是我找到的方法。我不能screen
从 rc.local使用或更好,如果我想使用它,我需要 root。我不想使用root。我现在的方法是使用crontab -e
它。
回答by Blaf
Inspired by both endorsed answers here I added the following function to my .bashrc
:
受到这里两个认可答案的启发,我将以下功能添加到我的.bashrc
:
Now I just use sscreen
instead of screen
and never have to think about the issue again.
现在我只是使用sscreen
而不是,screen
再也不用考虑这个问题了。