2014-01-24 45 views
11

早上好, 我有问题。我想用一个脚本作为用户“XYZ”在屏幕上启动一个程序。 这是我的短格式脚本:屏幕无法打开您的终端'/ dev/pts/0' - 请检查

# 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 "$1" 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: $0 {start|stop|status|restart}" 
exit 1 
;; 
esac 
exit 0 

我想连接的屏幕,但我得到了这一点。

Cannot open your terminal '/dev/pts/0' - please check. 

我做错了什么?

回答

18

要解决该问题,请尝试运行script /dev/null作为用户su以启动screen之前。

script -q -c "su $USER -l -c \"screen -m -d -S $NAME $DAEMON start\"" /dev/null 

更多关于它:

+0

我知道这...但随后同样的错误 '的/ dev/PTS/2' 出现 –

+1

@FabianHarmsen:我见更新。试试这个吧,请 –

+0

@Ingor Chubin我无法启动服务器,但我已经在我的问题中设置了compte脚本,可能有帮助 –