Susan Arante writes ..
>I'm getting the above error when my perl script runs a batch
>(master.bat) that in turn runs a batch (slave.bat) that runs another
>perl script. The process kicks me out
sounds peculiar .. but I don't think it has anything to do with your
Perl5/Perl6 dance .. see comments on your code below
>open(CFGFILE, "ReStart_one.cfg");
>open(MASTERBAT, ">Master.bat");
>
>$mcname = <CFGFILE>;
so now $mcname contains a line from the file AND it's line-ending character
>while ($mcname ne "")
this 'ne ""' will ALWAYS be true because even on a blank line $mcname will
contain a line-ending character
>{
>chomp($mcname);
only here do you strip off that line ending character
>printf MASTERBAT ("Start slave.bat $mcname\n");
>printf MASTERBAT ("wait 5\n");
>
>NEXTMC:$mcname = <CFGFILE>;
this is a really strange way to do this .. take a look at the perlopentut
tutorial on opening and using files .. you'll see it done quite differently
>}
>close MASTERBAT;
>printf `master.bat`;
and finally .. a 'printf' without a pattern .. you should be using either
print - or just a system call (the batch file will print out to STDOUT
itself)
here's my code for doing the same thing
#!perl -w
use strict;
my $bat = 'Master.bat';
open CONFIG, 'ReStart_one.cfg' or die "Bad open: $!";
open BATCH , ">$bat" or die "Bad open: $!";
while(<CONFIG>)
{
chomp;
print BATCH "Start slave.bat $_\n" or die "Bad write: $!";
print BATCH "wait 5\n" or die "Bad write: $!";
}
close BATCH or die "Bad write: $!";
system $bat;
__END__
References:
perldoc perlopentut
perldoc -f open
perldoc -f printf
perldoc -f print
--
jason king
A Canadian law states that citizens may not publicly remove bandages.
- http://dumblaws.com/