#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    301
    Rep Power
    12

    Echo html in a batch file


    Hi gang,

    I need to echo html markup into a file via my batch file like this
    Code:
    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 >.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Have you tried using quotes?
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. I have a red lunch bag
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jan 2005
    Location
    The armpit of Niagara
    Posts
    3,125
    Rep Power
    339
    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.
    Web Design Tips - Posting and You

    If I've been helpful, and/or you're really nice, consider buying something from my Amazon.com wishlist.
    • There is no room for pride when trying to be the best at what you do.
    • Friends don't let friends use bad code.
    The club is dead.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    My file (html_test.sh):
    Code:
    #!/usr/local/bin/bash
    echo "<html><head>Test</head><body><a href=\"www.google.com\">google</a></body></html>" >> out.html
    I run:
    Code:
    ./echo_test.sh
    I get (out.html):
    Code:
    <html><head>Test</head><body><a href="www.google.com">google</a></body></html>
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  8. #5
  9. I have a red lunch bag
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jan 2005
    Location
    The armpit of Niagara
    Posts
    3,125
    Rep Power
    339
    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.
    Web Design Tips - Posting and You

    If I've been helpful, and/or you're really nice, consider buying something from my Amazon.com wishlist.
    • There is no room for pride when trying to be the best at what you do.
    • Friends don't let friends use bad code.
    The club is dead.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    301
    Rep Power
    12
    Correct I am on windows.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    301
    Rep Power
    12
    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
    Code:
    echo  ^<center^>^<a href="someur.com"^>something^</a^>^</center^> >> index.html

    Comments on this post

    • cybersaga agrees : Nice! I knew there had to be something like this, but I couldn't find it. Thanks for posting your solution.

IMN logo majestic logo threadwatch logo seochat tools logo