Answer the question
In order to leave comments, you need to log in
Is it possible in BASH to assign to a variable the result of executing CURL with a query containing another variable?
There is a task: there is a document in which set of lines. It is necessary to loop through all the lines from the file, each line must be used as part of the URL that is accessed when using CURL. We would also like to assign the result of the server execution to a variable, since the result must be processed and saved as a file.
#!/bin/bash
FILE=$1
while read LINE; do
RESULT=$(curl https://domain.com/get?foo1=$LINE)
echo "Это строка: $LINE & $RESULT"
done < $FILE
Answer the question
In order to leave comments, you need to log in
#!/bin/bash
FILE=$1
while read LINE; do
bla=`curl https://domain.com/get?foo1=$LINE`
RESULT=eval $bla
echo "Это строка: $LINE & $RESULT"
done < $FILE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question