unix shell中的语法错误

时间:2015-11-13 14:10:24

标签: shell unix

我有代码:

DATE=$(date --utc "+%FT%T.%N" | sed -r 's/[[:digit:]]{6}$/Z/');
JOBS_ID="\"56449e75e4b01da8ea330b9d\", \"56449e75e4b01da8ea330b68\", \"56449e75e4b01da8ea330b60\", \"56449e75e4b01da8ea330b53\", \"56449e75e4b01da8ea330b55\", \"56449e74e4b01da8ea330b2e\", \"56449e77e4b01da8ea330cac\""   
declare -a arr=($JOBS_ID)
for i in "${arr[@]}"
do
id=$( echo "$i" | tr -d , )
echo "Force a cease of RP launch, ID=$id"
curl --user user:pass -X PUT --header "Content-Type: application/json" --header "Accept: */*" -d "{ 
\"end_time\":\"$DATE\", 
\"status\": \"passed\" 
}" "https://<some_rest_resource>/api/v1/my_project/launch/$id/finish"
done

我的jenkins构建日志经常出现异常:

  

+ date --utc +%FT%T。%N + sed -r s / [[:digit:]] {6} $ / Z /   + DATE = 2015-11-13T13:58:51.162Z /tmp/hudson1799790879869363544.sh:4:语法错误:&#34;(&#34;意外的构建步骤&#39;执行shell&#39;标记构建   作为失败

在线语法检查员说一切都很好。请帮助我找到语法错​​误。

1 个答案:

答案 0 :(得分:0)

我发现你是shell脚本中的新手。 你必须表明标准化,研究员:

#!/bin/bash