Helpful Information
 
 
Category: Other Programming Languages
Echo html in a batch file

Hi gang,

I need to echo html markup into a file via my batch file like this


echo <center><a href=".....</a></center> >> index.html

Of course there is a lot more to the batch file than this but this is where it breaks. Is there a way to echo html markup into the new index.html?

I suspect that the batch file doesn't like < and >.

Have you tried using quotes?

Using quotes will unfortunately include the quotes in the output. I don't think there is a way you can do this with the echo command.

My file (html_test.sh):

#!/usr/local/bin/bash
echo "<html><head>Test</head><body><a href=\"www.google.com\">google</a></body></html>" >> out.html

I run:

./echo_test.sh

I get (out.html):

<html><head>Test</head><body><a href="www.google.com">google</a></body></html>

Well, he mentioned he wants to do this in a batch file, so I'm assuming he's on Windows. On Windows, the echo command will include the quotes; at least WinXP.

Correct I am on windows.

A light bulb came on a minute ago and I remembered that I had done this in another script probably 2 years ago and it works.

Here's how to include HTML in a Batch File for output as per my example.
USE THE CARROT


echo ^<center^>^<a href="someur.com"^>something^</a^>^</center^> >> index.html










privacy (GDPR)