2017-12-06 4 views
0

"bash tesh.sh 60s"와 같은 사용자 입력을 전달하려고합니다. 아래 curl 명령문을 사용하여 $ args1 변수에 사용하십시오.Curl & JFrog가 매개 변수에 변수를 허용하지 않습니다.

args1="$1" 

results=$(curl -s -username:password https://URL/artifactory/api/search/aql -H "Content-Type: text/plain" -d 'items.find({"repo":{"$eq" : "generic-sgca"}}, {"created" : {"$before" : "$args1"}})' | jq -r '.results[].path'|sed 's=/api/storage==') 

echo $results 

는하지만 내 결과는 다음과 같습니다

parse error: Invalid numeric literal at line 1, column 7 

나는 데이터의 정상적인 출력을 기대하고있을 때. 구문에 어떤 문제가 있습니까?

답변

0

인수를 지원하지 않는 작은 따옴표 문자열로 인수를 삽입하려고합니다 (this great stackoverflow answer 참조).
큰 따옴표 문자열을 사용할 수 있습니다.

args1="$1" 

results=$(curl -s -username:password https://URL/artifactory/api/search/aql -H "Content-Type: text/plain" -d "items.find({\"repo\":{\"$eq\" : \"generic-sgca\"}}, {\"created\" : {\"$before\" : \"$args1\"}})\" | jq -r '.results[].path'|sed 's=/api/storage==') 

echo $results 
관련 문제