James
James

Reputation: 197

Instructing a batch file to do something depending on output

I have a situation where I would like the a batch file to do one of two different actions.

E.g. I am using WGET to download a file:

Situation 1: WGET outputs "404 Not Found" - start batch1.bat

or

Situation 2: WGET outputs "Download successful" - start batch2.bat

Any help would be greatly appreciated

Upvotes: 1

Views: 607

Answers (1)

Philip Kelley
Philip Kelley

Reputation: 40359

Does WGET raise an error (as detected by ERRORLEVEL) when it hits a 404 Not Found? If so, include somethihg like

IF errorlevel == 1 GOTO :WGET_Error

immediately after the call. If not, you might have to redirect the output to a file, read and parse the file (perhaps using the FOR command) to see if the first line is "404 Not Found", and go from there.

Upvotes: 1

Related Questions