0

I'm trying to pass user input like "bash tesh.sh 60s" and have the curl statement below take that input and use it for the $args1 variable.

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

But my results are:

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

When I'm expecting a normal output of data. What's wrong with my syntax?

VivaLaRobo
  • 463
  • 5
  • 14

1 Answers1

1

You are trying to interpolate an argument inside a single quotes string which does not support it (see this great stackoverflow answer).
You can use a double quotes string:

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
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57