not able to echo the output in dos

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

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%

regards
AbdulWahab


See More: not able to echo the output in dos

Report •

#1
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
echo.%lcl%

rem make use of the single space
echo%lcl%

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

http://www.computing.net/howtos/sho...

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