【问题标题】:Custom script in .screenrc.screenrc 中的自定义脚本
【发布时间】:2010-03-03 17:36:51
【问题描述】:

我编写了一个脚本来生成远程 shell 或运行本地 shell,无论它是否在当前机器上:

#!/bin/bash
# By:  benoror <benoror@gmail.com>
#
# spawns a remote shell or runs a local shell whether it's on the current machine or not
# $1 = hostname

if [ "$(hostname)" == "$1" ]; then
    bash
else
    ssh "$1.local"
fi

例如,如果我在 server1 上:

./spawnshell.sh server1   -> runs bash
./spawnshell.sh server2   -> ssh to server2.local

我希望该脚本在 GNU Screen 的单独选项卡中自动运行,但我无法让它运行,我的 .screenrc:

...
screen -t "@server1"  1   exec /home/benoror/scripts/spawnshell.sh server1
screen -t "@server2"  2   exec /home/benoror/scripts/spawnshell.sh server2
...

但它不起作用,我尝试过不使用“exec”,使用 -X 选项等等。有什么想法吗?

【问题讨论】:

  • *我使用 Avahi (wiki.archlinux.org/index.php/Avahi) 配置了域查找
  • 当您说“它不起作用”时,这并不能告诉我们太多。告诉我们它做了什么以及您收到的错误消息会很有帮助。另外,当您在屏幕上键入 exec 命令时会发生什么 ^A-:-prompt?
  • “为我工作”。您是否使“spawnshell.sh”可执行?试试screen 2&gt;$HOME/err,看看你的主目录中的err文件里有什么。

标签: linux bash shell gnu-screen


【解决方案1】:

我使用以下:

screen -t gmail alpine -i -p $HOME/.pinerc-gmail
screen -t work  alpine -i -p $HOME/.pinerc-work

而且效果很好。 1和2是干什么用的?你试过删除它们吗?

你能用 spawnshell 以外的其他程序试试吗?也许启动 vim 和 emacs?如果这些工作,那么你的脚本有问题,而不是你的 screenrc。

【讨论】:

    猜你喜欢
    • 2022-10-20
    • 2013-03-26
    • 2021-07-20
    • 2019-12-01
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多