Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ECHO-ing special characters into output file

Status
Not open for further replies.

Hexonx

Programmer
Jan 10, 2001
102
US
I'm using a tool to generate a C# code file and am using the ECHO command to do it. I need need to write this line to the output file:

//<autogenerated>

but I keep getting a syntax error message. I tried this:

"//<autogenerated>"

but the quotes are retained in the output file.

This is an example of what I need:

cmd.exe /C echo //<autogenerated> > out.txt

to generate the file, out.txt that contains this single line:

//<autogenerated>


What am I doing wrong here? Is there a way to escape the special characters?
 
Hello Hexonx,

Try this.
Code:
for /f "tokens=1*" %%a in ('//<autogenerated>') do echo %1 >>out.txt
regards - tsuji
 
Correction:

Consistently double up % only for batch process. Hence use %a rather at command prompt.

- tsuji
 
Tsuji,

Thanks for the info. I'm running on Win2k and it still complains about the < and > characters. The code you sent was close, but here's what worked at the command line (except for < and >):

for /f "usebackq tokens=1*" %a in ('//autogenerated') do @echo %a > out.txt
 
Hexonx,

If I fall to simpler approach, it seems to work all right.
Code:
for /f %a in ("//<autogenerated>") do @echo %a > out.txt
- tsuji
 
That did it, my friend!

This is good to know, since XML is so prevalent these days and the command processor has such difficulty processing special characters.

Thanks, again!
 
Hexonx,

It is indeed a need-to-know workaround. Legacy escape sequence type is not going to work.

- tsuji
 
Now if only you could send a zero 0 for a COM applicaton...
 
O/S Windows XP Pro, upon booting I receive Pri Master Hard Disk S.M.A.R.T. status BAD, Backup and Replace press F1 to resume. The Amibios is American Megatrends Inc., the Hard Disk is: Maxtor 40GB. I found the tools to download to the flopy drive, and it stated that I had no problem with the hard drive. The amibios still gives 2 beeps prior to booting, and still gives the message status BAD. All help is greatly appreciated. DiamondMax 40 Model Maxtor 96147U8. Capacity 40 GB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top