腳本內容:
[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"
}
執行腳本,報錯
[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: `}'
解決辦法:
就多了個空格而已,而已,而已
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。