溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

sh腳本except行報(bào)錯(cuò)問題

發(fā)布時(shí)間:2020-07-23 09:40:23 來(lái)源:網(wǎng)絡(luò) 閱讀:739 作者:玉骨 欄目:網(wǎng)絡(luò)安全

腳本內(nèi)容:

[root@m01 scripts]# cat fenfa_sshkey.exp 

[root@m01 scripts]# cat fenfa_sshkey.exp

#!/usr/bin/expect

if { $argc != 2 } {   

 send_user "usage: expect fenfa_sshkey.exp file host\n"   

 exit   


#define var

set file [lindex $argv 0]

set host [lindex $argv 1]

set password "123456"

spawn ssh-copy-id -i $file " $host"

 expect {

"yes/no"    {send "yes\r";exp_continue}

"*password" {send "$password\r"}

}

expect eof


exit -onexit {

  send_user "Oldboy say good bye to you!\n"

}

執(zhí)行腳本,報(bào)錯(cuò)

sh腳本except行報(bào)錯(cuò)問題

[root@m01 scripts]# /bin/sh -x /server/scripts/fenfa_sshkey.exp 

/server/scripts/fenfa_sshkey.exp: line 15: syntax error near unexpected token `}'

/server/scripts/fenfa_sshkey.exp: line 15: `}'

解決辦法:

sh腳本except行報(bào)錯(cuò)問題

就多了個(gè)空格而已,而已,而已

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI