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

Hi, I am using Net::Telnet to connect to an equipments console. I am able to send commands and receive responses to my commands. But I am unable to get the system logs which the equipment puts on to this console at real time. I get these logs as a response to my next command. The result is that, as I check for a particular regex as the response to my commands, and the system logs also have similar syntaxes, it matches the regex and actually displays the system logs as the response of my command. Need your wisest advice. Thanks!

Replies are listed 'Best First'.
Re: Net::Telnet Question
by pg (Canon) on Nov 19, 2004 at 15:32 UTC
    "I get these logs as a response to my next command. "

    I can think of two pissiblities:

    • Your Prompt parameter might be wrong, and Telnet was confused and thought it hasn't receied the last part respnse. For example:
      my $t = new Net::Telnet(timeout => 10, input_log => $file, Prompt => " +/\[AAUA1\]/");
    • Your last part response is not flushed to your screen. Force it to flush like adding a "\n". However, most likely, there should be a "\n" at the end of the response already.
      I do not use "Prompt =>" thing because on my login, I do not get a prompt (or different than) and I get a prompt for my commands.

      I did not understand the "\n" part of what you said. Do you mean sending a "\n" once in a while during non-interactive period? The sequence of commands I use are

      new Net::Telnet() $telnet->print() $telnet->waitfor()

      $telnet->cmd() makes my things complicated as I have to specify the prompt which I cannot with one regex.

      Thanks

        I think you're going to have to be more explicit. I can only guess that your problem is that you want to read all text output (the log) until your regex matches what should be the prompt for a new command, and its matching something in the log instead?

        If so, what is your regex exactly, whats the prompt you want to match, and what is in the system log that is getting matched instead?

        If thats not it, then I've no clue, sorry.

        C.