我在屏幕的每个窗口上都有多个任务要完成。我需要用一些简单的脚本来实现它的自动化。如有任何帮助,我们将不胜感激。
Start a Screen named "XYZ" with window "1"
Start a another window "2"
Run a particular command on the window "1"
Run a particular command on the window "2"
This can continue for multiple windows,
needed simple API's to achieve this.
我从屏幕手册页中了解到,我们可以使用带有-X
开关的屏幕向特定的屏幕和窗口发送命令。
'-X' - Send the specified command to a running screen session.
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.'
Source: http://www.gnu.org/software/screen/manual/screen.html
我刚刚将屏幕命令封装在python API中,所以只编写一个python脚本就足以使我的工作自动化。
For creating a screen, creating a window and then sending commands.
`https://github.com/innosam/screenapi`
您可以将tmux视为屏幕的替代方案。除其他外,它的控制模式允许应用程序使用简单的纯文本协议与tmux通信。
您可以尝试如下:
# Default screens
screen -t shell1 0
screen -t shell2 1
screen -t server 2 ssh me@myserver
请参阅GNU屏幕的redhat指南
希望这能有所帮助。