albob has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl open pipe exiting early
by RichardK (Parson) on Apr 03, 2015 at 11:39 UTC | |
by albob (Sexton) on Apr 03, 2015 at 12:07 UTC | |
by albob (Sexton) on Apr 03, 2015 at 13:03 UTC | |
by choroba (Cardinal) on Apr 03, 2015 at 13:44 UTC | |
by albob (Sexton) on Apr 03, 2015 at 14:55 UTC | |
by RichardK (Parson) on Apr 03, 2015 at 13:50 UTC | |
by albob (Sexton) on Apr 03, 2015 at 14:57 UTC | |
|
Re: Perl open pipe exiting early
by Anonymous Monk on Apr 03, 2015 at 10:47 UTC | |
by albob (Sexton) on Apr 03, 2015 at 11:34 UTC | |
by Anonymous Monk on Apr 03, 2015 at 23:40 UTC |