Page 1 of 1

echo >> hello.bat fail

Posted: 06 May 2010 13:57
by dani8190
i have typed this in cmd: echo echo hello >> hello.txt >> hello.bat
so the batchfile script on hello.bat is this: echo hello >> hello.txt
and when you starting hello.bat it will make hello.txt
in hello.txt: hello

but....
when i typing echo echo hello >> hello.txt >> hello.bat today the hallo.bat has a script like this:
echo hello.
where is >> hello.txt ?
what is wrong??

Re: echo >> hello.bat fail

Posted: 06 May 2010 14:07
by jeb
hi dani8190,

try it with escape characters

Code: Select all

echo echo hello ^>^> hello.txt >> hello.bat


without the escape character cmd.exe find the first >> hello.txt and suppose to pipe into that file
but then cmd.exe found >> hello.bat, and it decides not to pipe to hello.txt, but to hello.bat

jeb

Re: echo >> hello.bat fail

Posted: 08 May 2010 00:46
by Rastamind
or

Code: Select all

for %%a in (
"echo hello >> hello.txt"
) do echo %%~a >> hello.bat