cjay has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a question on Telnet sessions. I am in a situation where I need to parse the output of commands that are simlar to reboot(linux). Outputs that look similar to the below:

#<some command>

Broadcast message from root Thu Jun 23 11:05:47 2011...

The system is going down for reboot NOW !!

Currently , I am using Net::Telnet for the sessions.All this time I have been using the waitfor method , looking for the prompt to capture the output. I am not sure if I could use the waitfor() method here as there is no prompt in this case .I am not sure how to capture the output.

Any hints would be really helpful.

Replies are listed 'Best First'.
Re: Telnet Session
by Sewi (Friar) on Jun 23, 2011 at 15:32 UTC

    From Net::Telnet on CPAN:

    ($prematch, $match) = $obj->waitfor($matchop);
    [...]
    You can specify more than one pattern or string by simply providing multiple Match and/or String named parameters.

    Use waitfor to wait for your prompt and the shutdown message. Try

    $match =~ /The system is going down for reboot/

    when waitfor returns to decide if you got a prompt or shutdown message.