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

Where in the documentation of Control::CLI did you find that usage?

That is the syntax for sending a command to the remotely connected device. That part works fine...

Maybe consider checking whether your open call succeeds at all

I can see my open works in the logs created by Control::CLI. I can see in the input and debug logs the output of the tailer command.

But if you're using ssh anyway, why not run the commands directly through it?

In earlier code (not shown), I am connected to another blade on the machine already. The command in my open call is so I can SSH from the already established connection to another blade on the server. Straight SSH won't work in this case...

Thank you Corjon for the feedback - I truly appreciate it!!

  • Comment on Re^2: Read Pipe, Never Enters While Loop

Replies are listed 'Best First'.
Re^3: Read Pipe, Never Enters While Loop
by Corion (Patriarch) on Jun 02, 2017 at 20:02 UTC

    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.

      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...