Hallo all,
I have a rather simple question :
this works :
@echo on
for /f "delims=" %%g in ('findstr /I /R /C:"^ *.testdata" %file%') do set var=%%g
Output : ... set var=2: <testdata file="someFile.txt"/>
But when I try to do this :
@echo off
for /f "delims=" %%g in ('findstr /I /R /C:"^ *.testdata" %file%') do set var=%%g
echo. %var%
I get this output :
D:\Tools\eclipse\Workspace\testHtml>set var= <testdata file="someFile.txt"/>
The syntax of the command is incorrect.
D:\Tools\eclipse\Workspace\testHtml>echo. <testdata file="someFile.txt"/>
If I remove the echo then the error message dissapears. Any ideas?
Regards
Stefanos
Weird Problem with echo command
Moderator: DosItHelp
Re: Weird Problem with echo command
The result is the expected result in a batch file
Because in batch the variables are expanded before the code is executed.
So you got a line
So you try to redirect to/from some obscure locations.
To avoid this you can use quotes, or the delayed expansion with **!** instead of **%**
hope it helps
jeb
Because in batch the variables are expanded before the code is executed.
So you got a line
Code: Select all
echo.<testdata file="someFile.txt"/>
So you try to redirect to/from some obscure locations.
To avoid this you can use quotes, or the delayed expansion with **!** instead of **%**
Code: Select all
setlocal EnableDelayedExpansion
echo.!var!
hope it helps
jeb
-
- Posts: 2
- Joined: 12 Apr 2011 04:49
Re: Weird Problem with echo command
Outstanding...It didn't occur to me that the echo would try to redirect the xml stuff :S
Now it works! Thanks a bunch!
Now it works! Thanks a bunch!