如何执行Shell脚本并继续键入?
我正在尝试将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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论