Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

bash and curl question

Name: Anonymous 2008-10-25 19:25

im telling curl to download a range of files, like `curl -Of www.foo.com/bar[000-999].log` and id like to have two separate counters in bash, one for attempted downloads, and another for successful downloads, so i can calculate a success rate at the end of the downloading. how would i do this?

Name: Anonymous 2008-10-25 19:28

With a tidbit of string interpolation, some math, seq, and a for loop.

Name: Anonymous 2008-10-25 19:32

what i'm really trying to figure out, though, is how to figure out when curl is successful. i can get the attmpted counter working, but i'm not sure how to get the success counter to work

Name: Anonymous 2008-10-25 19:33

ooo, seq looks handy. didn't know about that one, thanks.

Name: Anonymous 2008-10-25 19:38

Unix commands return 0 upon success. The 0 stands for the number of errors it encountered during program execution.

Name: Anonymous 2008-10-25 19:48

thanks, guys. lemmie go experiment.

Name: Anonymous 2008-10-25 19:54

>>3
RTFMP

Name: Anonymous 2008-10-25 20:00

yay, works.
thanks a bunch.


attempt=0
success=0
until [ $attempt = "50" ]
do
    curl -Of "$urlBase/0$attempt.jpg" && let success++
    let attempt++
    echo "attempt = " $attempt
    echo "success = " $success
done
clear
echo "success rate:"
echo $success/$attempt|bc -l

Name: Anonymous 2008-10-25 20:57

>how would i do this?

In PowerShell

Name: Anonymous 2008-10-26 14:37

The 0 stands for the number of errors it encountered during program execution.
Best troll yet.

Name: Anonymous 2008-10-26 15:22

>>9
Please die.

Name: Anonymous 2011-02-03 2:57

Name: Anonymous 2011-02-03 7:30

Name: Anonymous 2011-02-04 16:48

Don't change these.
Name: Email:
Entire Thread Thread List