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