echo >> hello.bat fail

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dani8190
Posts: 7
Joined: 17 Mar 2010 03:15

echo >> hello.bat fail

#1 Post by dani8190 » 06 May 2010 13:57

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??

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: echo >> hello.bat fail

#2 Post by jeb » 06 May 2010 14:07

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

Rastamind
Posts: 2
Joined: 19 Mar 2009 19:17

Re: echo >> hello.bat fail

#3 Post by Rastamind » 08 May 2010 00:46

or

Code: Select all

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

Post Reply