0

我制作了一个脚本,它生成一个远程 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 选项等等。有任何想法吗 ?

4

1 回答 1

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。

于 2010-04-05T20:01:45.270 回答