這篇文章主要介紹“如何使用expect實現(xiàn)的自動登錄到多臺服務(wù)器”,在日常操作中,相信很多人在如何使用expect實現(xiàn)的自動登錄到多臺服務(wù)器問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何使用expect實現(xiàn)的自動登錄到多臺服務(wù)器”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

代碼如下:
#!/usr/bin/expect -f
set ipaddress [lindex $argv 0]
set passwd [lindex $argv 1]
set timeout 30
spawn ssh root@$ipaddress
#expect "yes/no"
#send "yesr"
expect "password:"
send "$passwdr"
expect "]*"
send "mkdir -p /tmp/haha/haha2r"
send "exitr"
***************
expect {
"(yes/no)?" {
send "yesn"
}
"password:" {
....
}
判斷語句
if {$havepass == 0} {
expect "password:" { send "$pwn" }
}
或者:
expect {
"yes/no" { send "yesr"; exp_continue}
"password:" { send "$passwdr" }
}
到此,關(guān)于“如何使用expect實現(xiàn)的自動登錄到多臺服務(wù)器”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
當前文章:如何使用expect實現(xiàn)的自動登錄到多臺服務(wù)器-創(chuàng)新互聯(lián)
文章URL:http://chinadenli.net/article20/dhecco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、Google、關(guān)鍵詞優(yōu)化、網(wǎng)站制作、網(wǎng)頁設(shè)計公司、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容