开发者

Instructing a batch file to do something depending on output

开发者 https://www.devze.com 2023-03-04 21:19 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消