in reply to Using File::Temp Names

How do you call ScriptB? Or should I say, when do you call ScriptB?

Files created with File::Temp may get removed as soon as the File::Temp object (file handle) goes out of scope (at least as long as you use, as you do, UNLINK=>1). So, are you sure the file handle is still live in scriptA when ScriptB tries to open the file by name?

Update: Rereading your code, I note that the functions are closures, so unless you have code to explicitly undef or assign to $tmpParamFileHandle, they're likely to keep the file handle alive. Until global cleanup, that is. So, I guess the question is: Are you sure ScriptB is trying to open this file before scriptA exits?

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: Using File::Temp Names
by novicepl (Initiate) on Aug 01, 2006 at 03:35 UTC
    Yes, file handle is still alive in ScriptA. To check I browsed the file using scripts shown below, before and after passing it to ScriptB.
    print "\n\n\n"; print "\n".getTempParamFileName()."\n"; open (AAA, "<".getTempParamFileName()); while(my $xxx=<AAA>){ print $xxx; } close AAA; ######### my @pmcmd=("$binDir/runWorkflow.pl", "-c", "$cluster", "-n", "$node", "-f", getWorkFlowFolder($feeder), "-p", getTempParamFileName(), + "-w", getWorkFlow($feeder)); $rc = PB::FileUtils::execute(\@pmcmd, $log); ######### print "\n\n\n"; print "\n".getTempParamFileName()."\n"; open (AAA, "<".getTempParamFileName()); while(my $xxx=<AAA>){ print $xxx; } close AAA;

      What's PB::FileUtils? Even google does not seem to know ...

      Does it execute runWorkflow.pl (ScriptB?) immediately and synchronously, on the same machine, under the same chroot, and with the same privileges (user/group)?

      Or, perhaps more easily answered, if you just run it with system {@pmcmd[0]} @pmcmd, does it see the file?

      print "Just another Perl ${\(trickster and hacker)},"
      The Sidhekin proves Sidhe did it!

        PB::FileUtils is our own module.
        ScriptsB is ran through above mentioned package as
        ... $cmd=join(' ', @$args); $output=`$cmd`; ...
        Probably this is opening child process and executing the ScriptB using the temp filename passed as a parameter. What is the solution in this case. How can child process access the temp file?