Sh script except line error problem
Content of the script:
[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"
}
Execute the script and report an error
[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: `}'
Solution:
It's just an extra space, that's all.