Loading ...
Sorry, an error occurred while loading the content.

continuing Net::Telnet to another sub routine?

Expand Messages
  • Noah
    Hi there, I open a new Net::Telnet session in loginJuniper but I want to continue that same session in parseJuniperPing - how do I go about doing that? but I
    Message 1 of 1 , Feb 27 4:04 PM
    • 0 Attachment
      Hi there,

      I open a new Net::Telnet session in loginJuniper but I want to continue
      that same session in parseJuniperPing - how do I go about doing that?

      but I get the following error:

      % ./pingandtrace.pl
      Can't call method "prompt" on an undefined value at ./pingandtrace.pl
      line 119.



      sub loginJuniper {
      my $s_TelnetAddr = shift;
      my $s_TelnetDev = shift;
      my $t = new Net::Telnet (Timeout => 10,
      Errmode => 'return',
      Prompt => '/Password:/'
      );
      $t->open("$s_TelnetAddr");
      $t->waitfor(-match => "/.*\:/");
      $t->print("globs");
      $t->waitfor(-match => "/.*\:/");
      $t->print("globs");
      $t->waitfor(-match => "/.*\:/");
      $t->print("set cli screen-length 0");
      }


      sub parseJuniperPing {
      my $l_routing_instance = shift;
      my $l_ping_address = shift;
      my $t;
      my $prompt = $t->prompt("/.*\>/"); <<<<<<<<<< line 119

      my @lines = $t->cmd("ping routing-instance $l_routing_instance
      $l_ping_address\
      ");

      undef ($t);
      foreach my $line (@lines) {
      print FILE "$line\n";
      }

      $t->waitfor(-match => "/.*\>/");
      my @lines = $t->cmd("traceroute routing-instance $l_routing_instance
      $l_ping_a\
      ddress");

      undef ($t);
      foreach my $line (@lines) {
      print FILE "$line\n";
      }
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.