首页 > 代码库 > sh脚本except行报错问题

sh脚本except行报错问题

脚本内容:

[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: `}‘

解决办法:

技术分享

就多了个空格而已,而已,而已

本文出自 “11837542” 博客,请务必保留此出处http://11847542.blog.51cto.com/11837542/1863161

sh脚本except行报错问题