0

I am trying to connection to Neptune DB and getting vertices details using CURL command. I have shell script for it. But somehow variable data is not going through it gremlin query. I have one Orgid.txt file where tenantid is present and my shell script reading the file and passing it to "name" variable

#!/bin/bash

i=1

rm VerticesCount1

while IFS= read -r line
do
name="$line"
#echo "Orgid name is "$i": $name"
curl -X POST https://<Neptune_endpoint>:<port>/gremlin -d '{"gremlin":"g.V().has(\"system.tenantId\",\"$name\").count()"}' >> VerticesCount1
#printf "\n"
echo >> VerticesCount1
((i=i+1))
done < Orgid.txt
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
ashis dash
  • 27
  • 5

2 Answers2

0

it is working fine with this code.

while IFS= read -r line
do
name="$line"
#echo "Orgid name is "$i": $name"
curl -X POST https://<Neptune_endpoint>:<port>/gremlin -d '{"gremlin":"g.V().has(\"system.tenantId\",\"'$name'\").count()"}' >> VerticesCount1
echo >> VerticesCount1
done < Orgid.txt
ashis dash
  • 27
  • 5
  • 1
    Please consider including a brief explanation of [how and why this solves the problem](https://meta.stackoverflow.com/q/392712/13138364). This will help readers to better understand your solution. – tdy Nov 03 '21 at 21:08
0

As with your other question I tested with a simple data file and it works fine. However, note how I changed the type of quotes used by curl.

i=1

while IFS= read -r line
do
name="$line"

curl -X POST https://mydbcluster.cluster-xxxxxxxxxxxx.us-east-1.neptune.amazonaws.com:8182/gremlin -d \
"{\"gremlin\":\"g.V().has('code','$name').count()\"}"
((i=i+1))
done < values.txt

which produces

{"requestId":"4e3e80ed-efcb-40a7-b92b-366c6f391d4e","status":{"message":"","code":200,"attributes":{"@type":"g:Map","@value":[]}},"result":{"data":{"@type":"g:List","@value":[{"@type":"g:Int64","@value":1}]},"meta":{"@type":"g:Map","@value":[]}}}{"requestId":"6a269b5b-32f6-49d2-a31d-c51dd52eba29","status":{"message":"","code":200,"attributes":{"@type":"g:Map","@value":[]}},"result":{"data":{"@type":"g:List","@value":[{"@type":"g:Int64","@value":1}]},"meta":{"@type":"g:Map","@value":[]}}}
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • Thanks a lot Kelvin. for me it worked by just adding '$name'. anyway your answers are helping a lot – ashis dash Nov 03 '21 at 17:32
  • I saw you unselected the accept to my answer and posted your own answer and accepted that, which is your choice, but it would be good to edit your answer to explain what the changes were as people often look to the accepted answer first. – Kelvin Lawrence Nov 12 '21 at 15:24
  • I haven't verified practically your solution Kelvin. this weekend I will verify and update you on this.. – ashis dash Nov 25 '21 at 03:24