linux - Shell GNU-Screen -X Stuff 问题

标签 linux bash shell printf gnu-screen

OPTIONS="java -Xms1024M -Xmx1024M -jar craftbukkit.jar"
PROCESS=server01

screen -dmS $PROCESS $OPTIONS nogui             # Starting the application
screen -x $PROCESS -X stuff `printf "stop\r"`   # Closing the application
screen -x $PROCESS                              # Attaching to the terminal of the application

该应用程序在开始时运行良好,但是我在使用 stuff 'printf "stop/r"' 时遇到问题 刚启动的时候好像不行,等了一段时间再尝试用上面的命令停止。但奇怪的是,如果我执行了 screen -x $PROCESS 和 detach (ctrl-A & ctrl-D) 然后我使用了 Stop 命令它确实有效。那么有没有办法在没有screen -x $PROCESS的情况下stuff printf

最佳答案

添加参数 -p 0 应该可以解决这个问题。像这样:

screen -x $PROCESS -p 0 -X stuff `printf "stop\r"`

(来自 screen 文档:-p window 如果存在,则预选指定的窗口。)

关于linux - Shell GNU-Screen -X Stuff 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13829310/

相关文章:

linux - 当我在我的一个文件上使用 mv 时,它消失了

php - 解析电子邮件附件的脚本

c - c 程序中的 echo 变量

bash - Bash中单引号和双引号之间的区别

linux - 如何在 Linux shell 脚本中声明?

Python 找不到自定义 PyQt5

python - 使用单个 os.mkdir 函数生成超过 1 个目录 (Python)

shell - 如何在 sh 中向变量追加换行符?

linux - 一次循环两个不同的变量,Linux,unix

bash - bash 读取 while 循环中的 "allowed"操作