I have a small Win7 dos batch and I am wondering how to do it right. Here what I do:
@echo OFF
@FOR %%D IN (*.sqlite) DO (
sqlite3 %%D "pragma integrity_check;" > %%D.check
type %%D.check
set /p CHECK= < %%D.check
del %%D.check
echo "%CHECK%"
)
I would expect that CHECK is set to the result of sqlite output. Though “type” shows the expected result, CHECK is empty!
And I do not understand what I am doing wrong.
I also tried it without using a tmpfile
FOR /F "tokens=*" %%i in ('sqlite3 %%D "pragma integrity_check;"') do SET CHECK=%%i
but this also does not work…
I’d appreciate any help/hint.
Tnx in advance,
Robert
Checkis set to the correct value, but you can’t see it withecho %check%, as this line is expanded while parsing the complete FOR-block, not at the execution time.You can change to delayed expansion or a simple call :subroutine.
or