New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Bash error
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 ?
Comments
line 4: [: -ne: unary operator expected
comes back
It seems to be running the inside of the while with nothing on the first run
Like a do while loop i guess instead of a while.
Interestingly the error goes when $1 is replaced with a file name
How about something like this?
May want to check for blank lines or comments in your list.