【问题标题】:Shell GNU-Screen -X Stuff problemsShell GNU-Screen -X Stuff 问题
【发布时间】:2012-12-11 22:08:14
【问题描述】:
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 并分离(ctrl-A & ctrl-D)然后我使用Stop 命令它确实有效。那么在没有screen -x $PROCESS 的情况下,有没有办法绕过stuff printf

【问题讨论】:

  • 您是否尝试过引用命令字符串 - 即screen -x $PROCESS -X "stuff `printf 'stop\r'`"
  • 不起作用。在执行第一个 screen -x $PROCESS 然后停止它之后,它甚至无法正常工作。

标签: linux bash shell printf gnu-screen


【解决方案1】:

添加参数 -p 0 应该可以解决它。像这样的:

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

(来自屏幕文档:-p window 如果存在,则预选命名窗口。)

【讨论】:

    猜你喜欢
    • 2012-08-03
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 2018-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-05
    相关资源
    最近更新 更多