Gnu-Screen:运行脚本,将命令发送到正在运行的屏幕会话
是否可以编写一个脚本来更改名称并打开对当前选项卡的监视(假设它正在屏幕中运行)?
谢谢。
Is it possible to write a script to change the name and turn on monitoring for the current tab assuming that it is being run in screen?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
从屏幕手册页:
基本上,
如果终端不在屏幕内运行,它会默默地发出错误:
您还可以将命令发送到特定会话,即使在分离时也是如此。 给定一个名为“main”的屏幕会话:
..您可以将最后一个活动窗口的标题发送到
blah
:..或一个特定窗口(在此名为
oldwindow
)示例):您可以使用进程 ID(来自
screen -ls
),而不是使用-x main
,也可以不使用窗口名称(-p oldwindow
)您可以使用窗口号:如果只有一个会话,则不必指定会话 PID 或名称。
From the screen manpage:
Basically, run
If the terminal is not running within screen, it silently errors:
You can also send the command to a specific session, even while detached. Given a screen session named "main":
..you can sent the title of the last-active window to
blah
:..or a specific window (named
oldwindow
in this example):Instead of using
-x main
you can use the process ID (fromscreen -ls
), also instead of using a window name (-p oldwindow
) you can use a window number:If there is only one session, you do not have to specify the session PID or name.
我认为这有效:
I think this works:
Screen声明了
$STY
环境变量,你可以尝试使用它。Screen declares
$STY
environment variable, you can try use it.您是否希望显示信息或与屏幕会话本身进行交互?
您可以使用以下命令发回消息:(http://www.slac.stanford.edu/comp/unix/package/epics/extensions/iocConsole/screen.1.html#lbAI)
Are you looking to display information or interact with the screen session itself?
You can send messages back with this: (http://www.slac.stanford.edu/comp/unix/package/epics/extensions/iocConsole/screen.1.html#lbAI)
屏幕透明运行,因此很难检测屏幕会话。 如果您尝试发送按键信息,这会起作用,并且如果您不在会话中,则会在您的终端中填充少量垃圾。
Screen runs transparently, so detecting the screen session is hard. If you try sending key presses, that would work, and would fill your terminal with a tiny bit of junk if you're not in a session.