2

I'm executing a shell script that utilizes wget to retrieve data from the web. I'm wondering if there's a way to instruct wget to terminate the process immediately upon encountering a 500 error code.

alexus
  • 13,374

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,374