not able to echo the output in dos

September 21, 2011 at 08:18:13
Specs: Windows XP

I have the below dos batch file which extracts some file value(always return some value) and trying to print this.but this

giving me o/p as

ECHO is on.

Can any guys help me out on this urgently...

set lcl=
for /f %%i in ('sqlplus -s usr/pwd@tst

@D:\tst\Purge_Utility\qt_counter.sql') do set lcl=%lcl% %%i
echo %lcl%


See More: not able to echo the output in dos

Report •

September 22, 2011 at 02:12:45
set lcl=%lcl% %%i

There is two problems here:

[1] "lcl" is undefined, so expands empty, on the first iteration so lcl contains a space at the start. "echo" can be used with leading spaces but you need to add a delimiter or even use the space to use "echo" normally.

rem will output leading spaces

rem make use of the single space

[2] Batch variable expansion can be counter intuitive at times:

In short:

SetLocal EnableDelayedExpansion


.... set lcl=!lcl! %%i

Or, if special chars aren't an issue:

.... call set lcl=%%%lcl%%% %%i

Report •
Related Solutions

Ask Question