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
Situ开发者_Python百科ation 2: WGET outputs "Download successful" - start batch2.bat
Any help would be greatly appreciated
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.
精彩评论