too many arguments
Question:
+ webcode='[Errno 111] Connection refused'
+ '[' '[Errno' '111]' Connection refused -eq 200 ']'
/data/update/sh/readup.sh: line 27: [: too many arguments
Solve Solutions:
if [ $webcode -eq 200 ] 变为
webcode=` /data/mon/monitor_http.py http://47.106.6.9:80/xtwlztdj_read_interface/cmd/version`
if [ "$webcode" -eq "200" ]
then
echo "read is sucess"
fi
Cause:
养成将所有字符串自变量用双引号括起的习惯,将除去很多类似的编程错误。
如果环境变量没放在双引号中,那么bash 认为条件中的自变量过多。
可以用双引号将字符串自变量括起来消除该问题。
看来是要养成将所有字符串自变量用双引号括起的习惯,将除去很多类似的编程错误。
see also
关于Shell 脚本中的"[: too many arguments"错误