我目前正在尝试从 bash 中分离 gnu 屏幕运行命令,但只需使用
screen -r myscreen
mycommand
不起作用。执行命令后无需脱离屏幕,因为该命令用于正常退出程序。
我也尝试过使用
{
mycommand
} | sudo screen -r myscreen
就像帖子上回答的那样程序内的 Bash 脚本命令,但是这会返回Must be connected to a terminal
,并附带未找到命令的错误。
有没有办法从 bash 执行 gnu 屏幕中的命令?
答案1
-S sessionname When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for screen -list and screen -r actions. It substitutes the default [tty.host] suffix. This name should not be longer then 80 symbols. -X Send the specified command to a running screen session. You may use the -S option to specify the screen session if you have several screen sessions running. You can use the -d or -r option to tell screen to look only for attached or detached screen sessions. Note that this command doesn't work if the session is password protected.
因此你可以使用:
screen -S myscreen -X your-command