Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个在屏幕会话中运行的服务器,我想向这个程序发送一个命令。我认为 screen -X 是我的答案,但我只能访问屏幕命令(标题、执行等)。
我需要能够像在程序中输入命令一样发送命令。有任何想法吗?
您可以将screen's-p和-Xoptions 与exec命令一起使用。
screen
-p
-X
exec
screen -X exec ".\!\!" echo foo例如,尝试将“foo”发送到屏幕中当前正在运行的程序。
screen -X exec ".\!\!" echo foo
screen -X exec ".!" echo foo如果第一个命令不起作用,您可能还想尝试。
screen -X exec ".!" echo foo