Page 1 of 1

problem with for loop

Posted: 12 Aug 2011 01:00
by pavankumar.thati
problem Description :
I need to get an output of active databases. For that i have writen the following code in suchaway that if the 4th line executes with out any error i'll echoed it as "Active" or "InActive".But in the following code for loop is executing once and skipping the rest of the iterations..
Please help me with this.


Code: Select all

@echo off
Setlocal EnableDelayedExpansion
For /F "tokens=*" %%a In ('mysql --user=%1 -p%2 -N -s -e "show databases"') do ( echo.skipped skipped
         mysql --user=%1 -p%2 --database=%%a -N -s -e "show tables">NUL 2>&1
         if ERRORLEVEL 1 (echo.%%a InActive ) else (echo.%%a Active)
         )


Output :

information_schema Active
skipped skipped
skipped skipped
skipped skipped

Re: problem with for loop

Posted: 13 Aug 2011 06:52
by aGerman
Does your mysql request return an ERRORLEVEL value?

Regards
aGerman

Re: problem with for loop

Posted: 16 Aug 2011 04:53
by pavankumar.thati
aGerman wrote:Does your mysql request return an ERRORLEVEL value?

Regards
aGerman

No Actually the ERRORLEVEL is set by DOS script not by mysql.Whenever mysql fails to run the The DOs script sets the ERRORLEVEL .....