Home > Blockchain >  Curl request stored in variable when executed using bash log failed and success urls
Curl request stored in variable when executed using bash log failed and success urls

Time:07-05

I used chrome devtools to get copy as curl request. but when i run it some failed. so how can i log success and failed url request

i had multiple curl requests stored in file or variable

eg. code

var='curl -X data -H Refferer:http://something.html "url.zip"'
IFS=$'\n'
for f in `echo "$var"`;
 do
echo "$f" | bash && echo "$f" | grep -Po 'http.*html' >> success || echo "$f" | grep -Po http.*html >> fail; done

But failed one were not being logged. Can someone help

CodePudding user response:

Grouping the commands solves it

var='curl -X data -H Refferer:http://something.html "url.zip"'
IFS=$'\n'
for f in `echo "$var"`;
 do
echo "$f" | bash && { echo "$f" | grep -Po 'http.*html' >> success; } || { echo "$f" | grep -Po http.*html >> fail; }; done
  •  Tags:  
  • curl
  • Related