How to check the status of call command in dos batch file -


i have batch file name xyz.bat these content

 @echo off  echo  1.cleaning 4 project.  call apacheant\bin\ant -buildfile clean-all.xml 

when first call end write on console build succeed or build failed.
how verify call failed or passed on condition basis want decide next call execution.

echo  1.building 4 project. call apacheant\bin\ant -buildfile build-all.xml @echo on 

echo  1.building 4 project. call apacheant\bin\ant -buildfile build-all.xml >logfile.txt findstr "succeed" logfile.txt >nul if errorlevel 1 (echo build failed) else (echo build succeeded) 

naturally, echo ... replaced 'set antstatus=succeed` if required.

don't try use errorlevel control processing since many commands change errorlevel report own status.

it may possible ant returns status on termination. check with

echo %errorlevel% 

after ant step. if returns errorlevel, don't need create , interpret logfile.

the if errorlevel syntax

if errorlevel n command_if_errorlevel_is_n_or_greater_than_n 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -