sh脚本except行报错问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh脚本except行报错问题相关的知识,希望对你有一定的参考价值。
脚本内容:
[[email protected] scripts]# cat fenfa_sshkey.exp
[[email protected] 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"
}
执行脚本,报错
[[email protected] 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行报错问题的主要内容,如果未能解决你的问题,请参考以下文章
解决Android的adb命令行报错Permission denied
报错记录解决Shell脚本报ambiguous redirect
REACT NATIVE 系列教程之十真机运行报错COMMAND /BIN/SH FAILED WITH EXIT CODE 1 的解决方法