1

I want to run a curl command, in which one parameter has to run through FOR loop. Say

curl -i -vs -X POST -H "$SESSION_TOKEN"  "http://$PLATFORM/videos/VIDEO_ID/play"

Here, the VIDEO_ID i want run it from 7500 to 8500 video id's. How can i do it?

3
  • Its in the shell script i am executing. A quick help is really helpful Commented Dec 23, 2014 at 21:09
  • write a loop... what's the problem? Commented Dec 23, 2014 at 21:12
  • Yup... sounds like you want a for loop. You might want to read through man bash if that's your shell (or man ksh or man sh or, if you really must and have no other alternatives, man csh). Commented Dec 23, 2014 at 21:19

2 Answers 2

3

Try doing this using :

for i in {7500..8500}; do
    curl -i -vs -X POST -H "$SESSION_TOKEN" "http://$PLATFORM/videos/$i/play"
done
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks.. its a great help.
1

Assuming that by "unix shell" you mean something like Bash, you can use an "arithmetic for loop":

for (( video_id = 7500 ; video_id <= 8500 ; ++video_id )) ; do
    curl -i -vs -X POST -H "$SESSION_TOKEN" \
        "http://$PLATFORM/videos/$video_id/play"
done

1 Comment

Beats you by 8 seconds ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.