create a batch file

Discussion in 'Perl Misc' started by king, Oct 23, 2007.

  1. king

    king Guest

    #!\c\perl\bin
    use strict;
    my $register="e0010088";
    open(fh,">check.bat")
    print fh "\@echo\n";
    print fh "\@echo Comparing X16 reg\n";
    print fh "check $register > test.log\n";
    print fh "fc /l log test.log > comp.log\n";
    print fh "find \"no differences encountered\" comp.log\n";
    print fh "if errorlevel 1 goto fail1\n";
    print fh "echo fine\n";
    print fh "del test.log\n";

    close (fh);

    while running this file to create a batch file I am getting a error
    saying error at print.

    I want to create a batch file named check.bat which should contain the
    below things: and the $ register value need to be replaced.
    ===============
    @echo
    @echo Comparing X16 reg
    check $register > test.log
    fc /l log test.log > comp.log
    find \"no differences encountered\" comp.log
    if errorlevel 1 goto fail1
    echo fine
    del test.log
    =================
    king, Oct 23, 2007
    #1
    1. Advertising

  2. On Tue, 23 Oct 2007 12:55:44 -0000, king <>
    wrote:

    >print fh "\@echo\n";
    >print fh "\@echo Comparing X16 reg\n";
    >print fh "check $register > test.log\n";
    >print fh "fc /l log test.log > comp.log\n";
    >print fh "find \"no differences encountered\" comp.log\n";
    >print fh "if errorlevel 1 goto fail1\n";
    >print fh "echo fine\n";
    >print fh "del test.log\n";


    In addition to the other gotchas mentioned by others, consider using a
    an here doc:

    print $fh <<"EOBATCH";
    \@echo
    \@echo Comparing X16 reg
    check $register > test.log
    fc /l log test.log > comp.log
    find "no differences encountered" comp.log
    if errorlevel 1 goto fail1
    echo fine
    del test.log
    EOBATCH


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
    Michele Dondi, Oct 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raterus
    Replies:
    1
    Views:
    939
    Patrice
    Apr 23, 2004
  2. Cyril Dex
    Replies:
    7
    Views:
    141,018
    sankalp.sawant59
    Mar 10, 2013
  3. Replies:
    3
    Views:
    894
    Andrew Thompson
    Feb 14, 2008
  4. Mozart
    Replies:
    7
    Views:
    3,809
  5. king

    create a batch file

    king, Oct 23, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    194
    A. Sinan Unur
    Oct 23, 2007
Loading...

Share This Page