Quantcast
Channel: LowEndTalk
Viewing all articles
Browse latest Browse all 39981

Bash error

$
0
0

Im struggling to understand why this happens.

Im wgetting thing by number from a list of numbers with the following script

#!/bin/bash
cat $1|while read line;do
wget --limit-rate=50k http://url/$line.json -O got-$line;
if [ "$?" -ne "0" ]; then
    rm got-$line;
fi
sleep 4;
done

Read the file passed each line try the URL and output it to got-number

If the wget command doesnt exit as 0 (it wasnt a 200 status code) - remove the file wget output

sleep for 4 second and try again

The output of this is using test.txt is

rm: cannot remove `test.txt': No such file or directory
--2012-12-30 12:18:06--  (start of wget output and everything works normal)

How can i stop it trying to remove the first file ?


Viewing all articles
Browse latest Browse all 39981

Trending Articles