Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am working with bash and I am trying to make a curl url call in a for loop.

Below is my simple curl call -

curl -v --header "Connection: keep-alive" "localhost:8080/user?userid=52010&client_id=20&attr=0"

And I am trying to make this curl call in for loop 100 times -

for ((i=1;i<=100;i++)); do   curl -v --header "Connection: keep-alive" "localhost:8080/user?uuid=52010&model_id=20&attr=0" done

I tried running above code as it is in the command line but it doesn't work and it gives me like this -

>

Any thoughts what wrong I am doing?

share|improve this question

closed as off-topic by devnull, Anthon, Ramesh, Braiam, terdon May 13 at 22:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – devnull, Anthon, Ramesh, Braiam, terdon
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Ah never mind. When the typo is fixed the error went away. That is the reason the question is closed :) Just to let the OP know :) –  Ramesh May 13 at 22:13

1 Answer 1

up vote 4 down vote accepted

You're missing a semicolon after the URL.

You have:

for ((i=1;i<=100;i++)); do   curl -v --header "Connection: keep-alive" "localhost:8080/user?uuid=52010&model_id=20&attr=0" done

It should be:

for ((i=1;i<=100;i++)); do   curl -v --header "Connection: keep-alive" "localhost:8080/user?uuid=52010&model_id=20&attr=0"; done
share|improve this answer
    
Silly mistake from me. One last question - Is there any way we can sleep between each curl call for few seconds? –  Webby May 13 at 20:05
    
Sure. Just put the sleep command before the done and add an extra semicolon. You can add as many commands as you want this way. for ((i=1;i<=100;i++)); do curl -v --header "Connection: keep-alive" "localhost:8080/user?uuid=52010&model_id=20&attr=0"; sleep 3; done –  yoonix May 13 at 20:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.