[英]Create a detached screen, send a command to it
I'm trying to do something which is proving suprisingly difficult.我正在尝试做一些事实证明非常困难的事情。 I want to create a screen session without attaching to it (since this will eventually become a startup script), then send a bash command to the session.
我想创建一个屏幕会话而不附加到它(因为这最终将成为一个启动脚本),然后向会话发送一个 bash 命令。
I've tried to simply echo Hello
in a newly created session.我试图在新创建的会话中简单地
echo Hello
。 The screen session is created fine but the echo never happens.屏幕会话创建得很好,但回声从未发生。 Given the following example, I would expect to finally attach to a screen which has "Hello" on it's console:
鉴于以下示例,我希望最终附加到控制台上显示“Hello”的屏幕:
screen -mdS "Test" # Create a screen session, do not attach to it
screen -ls # Confirm that the Test screen session exists
screen -S "Test" -X "echo Hello^M" # Send a command through
screen -R # Reconnect - notice the command didn't execute
But there's nothing in the session at all - the echo
was not executed.但是会话中根本没有任何内容 - 没有执行
echo
。 Any pointers are hugely appreciated?!任何指针都非常感谢?!
正确的调用是
screen -S "Test" -X stuff 'echo Hello\\r'
Try:尝试:
screen -S "Test" -X stuff 'echo "Hello"'`echo -ne '\\015'`
stuff is a screen command: screen docs for stuff command stuff 是一个屏幕命令: stuff 命令的屏幕文档
`echo -ne '\\015'`
means pressing Enter key `echo -ne '\\015'`
表示按Enter键
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.