in reply to Re^2: Read Pipe, Never Enters While Loop
in thread Read Pipe, Never Enters While Loop

What fails is your call to open.

If you don't check that, you will wonder forever why Perl does not seem to read from that file.

What works is your call to ->cmd, but that doesn't return a filehandle but the output of the command you run on the remote end.

Replies are listed 'Best First'.
Re^4: Read Pipe, Never Enters While Loop
by ImJustAFriend (Scribe) on Jun 05, 2017 at 13:03 UTC

    I added the code to die if open failed, and it doesn't die. Looks to me like open is working?

    open (PRM, "-|", $NE_obj->cmd("ssh $activepilotrcs reboot ; tailer PRM +")) or die "Could not open PRM: $!\n";; while (<PRM>) { print "DEBUG: $_\n"; if ($_ =~ m/.*FAILED HEARTBEAT.*/sxi) { print "$spacer $spacer $spacer $spacer Alarm Received That Act +ive Pilot Has Gone Down...\n"; } elsif ($_ =~ m/.*STARTING OA&M LEAD TRANSITION.*/sxi) { print "$spacer $spacer $spacer $spacer Standby Pilot $stdbypil +otrcs Has Started Transitioning To Active...\n"; } elsif ($_ =~ m/.*FAILOVER INITIALIZATION COMPLETED.*/sxi) { print "$spacer $spacer $spacer $spacer Standby Pilot $stdbypil +otrsc Has Transitioned To Active...\n"; $NE_output = $NE_obj->cmd("\003"); last; } else { next; } }

      Never mind, I changed the code to just tail a file and a foreach loop to print the lines read by tail... and got back a "File not found" message...