您好,登錄后才能下訂單哦!
腳本內(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ò)
[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: `}'
解決辦法:
就多了個(gè)空格而已,而已,而已
免責(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)容。