Hi all, I am having trouble with a perl open pipe where it seems to exiting from the called script early for some users. I have a script that talks to an SQL database, but before it even tries to communicate with the SQL database I have it printing a message stating that the script has started running:
# Subscript PrintLog("My sub-script is running...","i"); PrintLog("Yes, just to confirm I am running...","i"); ...etc...onto the SQL stuff
My main script then calls this as follows:
The problem I am seeing is that the print of text at the end can sometimes return any of the following:my $run_pid = open(RUN, "sub_script.pl $options 2>&1 |") or $sub_fai +led = 1; if (!$sub_failed) { $text .= "Entered if (!\$sub_failed) {\n"; while (<RUN>) { $text .= "Entered while (<RUN>)\n"; chomp; $_ =~ s/^\s*//; $text .= "$_\n"; } close(RUN); if ($? != 0) { $sub_failed = 1; } } else { $text .= "Failed to open sub_script.pl\n";} print "$text";
Entered if (!\$sub_failed) { or Entered if (!\sub_failed) { Entered while (<RUN>) or Entered if (!\$sub_failed) { Entered while (<RUN>) My sub-script is running... or Entered if (!\$sub_failed) { Entered while (<RUN>) My sub-script is running... Yes, just to confirm I am running.. and so on...
I am struggling to figure out what my be the cause of thinking the pipe is finished early. I have use piped opens in several places without issue so originally though that the issue was a due to a delay in connecting to the SQL server but the prints show that things can fall over even before I get to the SQL part of things.
Any advice/direction would be appreciated.
Thanks
Albob
In reply to Perl open pipe exiting early by albob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |