Reputation: 195
I'm using this sub for my prgram to wait up to several hours for a task to finish what it's doing on windows. When the windows task finishes, it updates a string in a text file to let the Linux script know that Windows is done.
I get this error while it's running: readline() on closed filehandle
Here is the sub
my $numberOfChecks = 28;
my $sleepTime = 900;
my $communicationsFile = "/home/user/ICAhome/Win_To_Linux_ComFile.txt";
my $winBuild = "1";
sub waitForWindowsBuild {
while ($numberOfChecks-- $$ $winBuild == "1"){
open (MYFILE, $communicationsFile);
while (<MYFILE>){
chomp;
if ($_ eq $buildValue){
$winBuild="1";
}
sleep($sleepTime);
}
close(MYFILE);
}
}
Could anyone tell me what's going on?
Thanks!
Upvotes: 0
Views: 3864
Reputation: 385506
Check if the open
succeeds. For example,
open (MYFILE, $communicationsFile)
or die("Can't open $communicationsFile: $!\n");
Upvotes: 1