在屏幕会话中向活动程序发送命令?
我有一个服务器在屏幕会话中运行,我想向该程序发送一个命令。我认为 screen -X 是我的答案,但我只能访问 screen 命令(标题、exec 等)。
我需要能够发送命令,就像我将其输入到程序中一样。有什么想法吗?
I've got a server running inside a screen session, and I want to send this program a command. I thought screen -X was my answer, but all that gives me access to is screen commands (title, exec, etc).
I need to be able to send the command as if I was typing it into the program. Any ideas?
您可以将
screen
的-p
和-X
选项与exec
命令结合使用。尝试 screen -X exec ".\!\!" echo foo,例如,将“foo”发送到屏幕中当前运行的程序。
您可能还想尝试 screen -X exec ".!" echo foo 如果第一个命令不起作用。
You may use
screen
's-p
and-X
options in conjunction with theexec
command.Try
screen -X exec ".\!\!" echo foo
, for example, to send "foo" to the currently-running program in the screen.You might also want to try
screen -X exec ".!" echo foo
if the first command is not working.