.screenrc 中的自定义脚本

发布于 2024-08-23 06:55:19 字数 893 浏览 4 评论 0原文

我制作了一个脚本,可以生成远程 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不吻晚风 2024-08-30 06:55:19

我使用以下方法:

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

效果很好。 1和2是做什么用的?您尝试过删除它们吗?

您可以使用spawnshell 以外的其他程序尝试一下吗?也许启动 vim 和 emacs ?如果这些有效,那么你的脚本有问题,而不是你的 screenrc 有问题。

I use the following:

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文