2

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?

ewwhite
  • 197,159
  • 92
  • 443
  • 809
alexus
  • 13,112
  • 32
  • 117
  • 174

2 Answers2

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

WinkyWolly
  • 598
  • 6
  • 19
0

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...

alexus
  • 13,112
  • 32
  • 117
  • 174