如何执行Shell脚本并继续键入?

发布于 2025-01-28 17:07:04 字数 368 浏览 3 评论 0原文

我正在尝试将SSH的SHEL脚本执行到跳跃服务器中,输入密码,然后能够在另一台服务器中输入命令或SSH。问题是脚本结束,我无法再输入命令并退出。

我不是那么精通外壳脚本,我希望别人做类似的事情。

#!/bin/bash
/usr/bin/expect <<EOD
spawn ssh [email protected]
expect "Password"
send "$1\n"
expect eof
$SHELL
EOD

I'm trying to execute a shell script that ssh's into a jump server, enter a password and then be able to enter commands or ssh into another server. The issue is that the script ends and I can't enter anymore commands and it exits.

I'm not that proficient in shell scripting, I was hoping someone else had done something similar.

#!/bin/bash
/usr/bin/expect <<EOD
spawn ssh [email protected]
expect "Password"
send "$1\n"
expect eof
$SHELL
EOD

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文