gpt4 book ai didi

linux - 如何以编程方式运行多个 screen ,每个 screen 都使用一个命令?

转载 作者:太空宇宙 更新时间:2023-11-04 03:37:11 25 4
gpt4 key购买 nike

我是 Linux screen 实用程序的新手,现在我必须创建很多 screen ,并传递每个 screen 一些命令。如何以编程方式实现这一目标,而不是使用(Ctrl+a c)创建每个 screen 并在其中键入命令?

最佳答案

使用 tmux 代替,tmux 具有更现代的 API,并且在大多数情况下易于使用。要使用 tmux 实现您的目的,您需要:

$ tmux new-session -s foo -d                # create a new session called foo
$ tmux new-window -t foo # create a new window
$ tmux send-keys -t foo.0 ./your_script.sh # window number starts with 0
$ tmux new-window -t foo # another new window
$ tmux send-keys -t foo.1 ./another_command # another of your script
...
$ tmux attach -t foo # attach to your session, escape key is ^b

关于linux - 如何以编程方式运行多个 screen ,每个 screen 都使用一个命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31155792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com