成都创新互联网站制作重庆分公司

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"

}

执行脚本,报错

sh脚本except行报错问题

[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行报错问题

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


标题名称:sh脚本except行报错问题
地址分享:http://cxhlcq.com/article/jjicih.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部