我想知道如何在屏幕会话中执行命令。
我搜索了一下,发现了这个:
screen -S nameofscreen -X stuff "command"
当我输入此命令时,命令会在屏幕内输入,但不会执行。
所以我的问题是如何使用此命令按 Enter 键。
我会做这样的事情:
screen -S sessionName bash -c 'cmd; exec bash'
它开始一个新的会话执行cmd
并启动 shell(否则它会删除该新会话)。
-X
will allow you to send input to a specified session -- that's why your command didn't execute. To execute it you'd need to add enter sign like Paul suggested. It can be done with Ctrl+v and then Enter. That will produce that ^M
. So:
screen -S sessionName -X stuff 'cmd^M'
然而,这本身并不会附加一个独立的会话。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)