I'm trying to get files from specific folder, load them with curl and get result to variable:
#!/bin/bash
shopt -s nullglob
FILES=*
for f in $FILES
do
core=$f
#echo "curl -H \"Content-Type: application/json\" --data-binary @$f http://v-cdh-master:8983/solr/$core/update/json?commit=true"
result=$(curl -H "Content-Type: application/json" -s --data-binary @$f http://v-cdh-master:8983/solr/$core/update/json?commit=true)
done
The result of running this script is
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
If I remove comment from echo string I could see the valid url like this
curl -H "Content-Type: application/json" --data-binary @affiliates_multival http://v-cdh-master:8983/solr/affiliates_multival/update/json?commit=true
Which works perfect when I copy/paste it to terminal.
Where is my mistake?