需求:
ssh 登錄到serverA
從A上再次登錄serverB
使用expect來實作,第一步很好寫,寫到第二步,就卡住了,我理解這時候需要再次使用spawn 起一個新的行程,但是如何做呢?
#!/bin/bash
/usr/bin/expect <<-EOF
spawn ssh root@<serverA>
set timeout -1
expect "password:"
send "root\n"
expect "#"
send "date\n"
send "ssh root@<serverB> \n" =====>這里有問題
expect "password:"
send "root\n"
interact
expect eof
EOF
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/252868.html
標籤:應用程序開發區
上一篇:shell編程去除回車符和換行符
下一篇:linux搭建ftp服務器
