I have text file that has arguments of curl command. This is how the file looks
'https://example.com/tl/' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username2",}'
'https://example.com/tl/' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username3",}'
'https://example.com/tl/' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username4",}'
'https://example.com/tl/' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username5",}'
'https://example.com/tl/' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username6",}'
This is the command I use
cat /AbsolutePath/Inputfile.txt | xargs -P 10000 -n 10 curl -s | jq '.message'
I'm using jq, to parse json in command line
What I want is,
- Pipe or send output of above command to another command, so that if
message
has certain text, grab the email value used in that corresponding curl command and write to a log file or create a filename with usernameX.txt
For example, only if username2 and username5 cURL command's message = 'success', these two usernames should be written to a log file or two files username2.txt and username5.txt should be created.
-P 10000
? Does your system have 10,000 CPU cores? Extremely unlikely, but if it does, do you want to bombard the remote server with 10,0000 simultaneous requests? and expect not to get your IP address blocked? 2. Why-n 10
? There aren't 10 args on each line. and xargs won't handle them the way you seem to think it does. 3. you'd be better off running curl from xargs inside ash -c
script. Or instead of xargs, use gnu parallel or even a simple for loop. 4. do you mean to pipe all of xargs' output into jq in one go (as you're currently doing), or once for each curl command?gnu parallel
can send 10000 requests despite computer having normal quad/octa core? I'm doing stress testing on my servers, so no worries on ip blocking. 2. I still couldn't wrap my head around -n and maxprocs. Is this-X POST
considered as one argument?ab
is in theapache2-utils
package. Other Linux distros probably have it in a similarly-named package.ab
. I did hear about it.