.screenrc 中的自定义脚本
我制作了一个脚本,可以生成远程 shell 或运行本地 shell,无论它是否在当前计算机上:
#!/bin/bash
# By: benoror <[email protected]>
#
# 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 选项等等。有什么想法吗?
I made a script that spawns a remote shell or runs a local shell whether it's on the current machine or not:
#!/bin/bash
# By: benoror <[email protected]>
#
# 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
For example, if I'm on server1:
./spawnshell.sh server1 -> runs bash
./spawnshell.sh server2 -> ssh to server2.local
I want that script to run automatically in separate tabs in GNU Screen, but I can't make it run, my .screenrc:
...
screen -t "@server1" 1 exec /home/benoror/scripts/spawnshell.sh server1
screen -t "@server2" 2 exec /home/benoror/scripts/spawnshell.sh server2
...
But it doesn't works, I've tried without 'exec', with -X option and a lot more. Any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用以下方法:
效果很好。 1和2是做什么用的?您尝试过删除它们吗?
您可以使用spawnshell 以外的其他程序尝试一下吗?也许启动 vim 和 emacs ?如果这些有效,那么你的脚本有问题,而不是你的 screenrc 有问题。
I use the following:
And that works great. What are the 1 and 2 for? Have you tried removing them?
Could you try it using another program than spawnshell? Maybe start up vim and emacs? If those work, then your script is at fault and not your screenrc.