Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i'm running a shell script that uses wget and pulls something over the web, my question is is there a way to tell wget to abort as soon as it hits 500 error code?

share|improve this question

2 Answers 2

You might want to check our curl as it's a bit more robust especially when handling things of that nature.

Now I don't know off the top of my head how to do what you want however curl has certain exit codes for certain events. This one may be of interest to you:

22

HTTP page not retrieved. The requested url was not found or returned another error with the >HTTP error code being 400 or above. This return code only appears if -f/--fail is used.

I would recommend checking out the curl man page

share|improve this answer
    
I can't use curl, I need to use wget. –  alexus May 25 '11 at 16:01
up vote 0 down vote accepted

I guess wget doesn't have a way to handle any errors at this point :( that's kind of sucks, unfortinetly curl won't work for me, but if something I think curl's way of handeling it would be the closest so to speak solution...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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