create a batch file

K

king

#!\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
=================
 
M

Michele Dondi

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top