Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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:


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


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.