Hi, I am trying to use my PERL script to write a DOS batch file, which can later be run from the command line. The problem is that the batch file output, which is essentially a text file, does not recognize the newline characters, and so is not formatted correctly.

Can anyone offer advice on how to write the output so that the results look like a properly formatted batch file?

my $outfile = "mybatchfile.bat"; open( OUTPUT, ">", $outfile) or die "Can't open file " . $outfile. " : + $!"; { print OUTPUT '@echo off\n setlocal\n set PATHNAME=C:\TEMP\%1_REGRESSION\n', 'set WAIT_TIME=240000\n set URL=\"http://myurl.biz\"\n', 'set PWD="megapassword"\n set EMAIL_TO_STRING="bob@test.com"; }
Output looks like:

@echo off\n setlocal\n set PATHNAME=C:\TEMP\%1_REGRESSION\n set WAIT_TIME=240000\n set URL=\"http://myurl.biz\"\n set PWD="megapassword"\n set EMAIL_TO_STRING="bob@test.com

instead of:
@echo off
setlocal
set PATHNAME=C:\TEMP\%1_REGRESSION
set WAIT_TIME=240000
set URL="http://myurl.biz"
set PWD="megapassword"
set EMAIL_TO_STRING="bob@test.com


In reply to Using perl to output a DOS batch file by skynelson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.