Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can I use the ECHO command to write an HTML tag to a text file?
I'm creating a DOS batch script to write some HTML tags to a text file.
If I type [b][color=red]echo HTML > output.txt[/color][/b] at command
prompt then the word [b][color=red]HTML[/color][/b] is correctly
written to a text file called "output.txt".
But if I try [b][color=red]echo > output.txt[/color][/b] then it
doesn't work, obviously because DOS is trying to interpret the that
are surround the word [b][color=red]HTML[/color][/b] .
I tried putting quotes around the tag, like this: [b][color=red]echo
"" > output.txt[/color][/b] but this stores the tag and the quotes
as well, which is no good.
The ideal solution would be to remove the quotes, but I have scanned the
Net and can't find how to do this.
Any ideas?
May

Geeze, did you read your post after posting it? This forum doesn't interpret "[b]" or "[color=red]" as font formatting. Another thing, this forum has some trouble in displaying the less-than character (<).
May wrote:
> But if I try [b][color=red]
> echo > output.txt[/color][/b]
> then itI think you meant something more, probably there was an HTML tag after the word "echo", right?
I'll be representing the less-than and greater-than characters as []'s. Example:
[HTML][BODY]
this is an HTML document
[/BODY][/HTML]Got it? Ok, let's say you want to create the following document via batch file:
[HTML]
[HEAD]
[TITLE]Sample HTML document[/TITLE]
[/HEAD]
[BODY bgcolor="red"]
Hello, Mama!
[/BODY]
[/HTML]This batch script would do it:
===== BATCH SCRIPT BEGIN =====
@echo off
echo %0? |FIND /i ".BAT?" > nul
if not errorlevel=1 set THIS=%0
if errorlevel=1 set THIS=%0.BAT
set char= %=%
set char= %char%
FIND "%char%" < %THIS% > sample.htm
for %%? in (char this) do set %%?=
goto eof[HTML]
[HEAD]
[TITLE]Sample HTML document[/TITLE]
[/HEAD]
[BODY bgcolor="red"]
Hello, Mama!
[/BODY]
[/HTML]:eof
===== BATCH SCRIPT END =====Note that the secction which have the HTML file has a double space on the beginning of each line. You MUST include that double space on all the lines which are going to the HTML file, and you MUST NOT include that combination of characters anywhere else on the batch.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

"Geeze, did you read your post after posting it? This forum doesn't interpret "[b]" or "[color=red]" as font formatting. "
Uh, he wasn't trying to. He was giving examples of what he wants to do in DOS.

Flea wrote:
> Uh, he wasn't trying to. He was giving
> examples of what he wants to do in DOS.I don't think so. Carefully read this:
May wrote:
> If I type [b][color=red]echo
> HTML > output.txt[/color][/b]
> at commandThe "tags" are ending after the filename, it doesn't seem to me that May is trying to ECHO those tags into the file output.txt, as you suggested.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |