in reply to Re^3: Can't get data from cisco router/switch when telnetting in via perl script.
in thread Can't get data from cisco router/switch when telnetting in via perl script.

monarch's comment is spot on. While I use the Net::Telnet::Cisco module I made a quick script just using Net::Telnet. Below is a script that logs into a 3750 switch and performs show clock. the switch's prompt is 3750G>. Without the prompt, the script simply times out.
use Net::Telnet; # use the telnet module my $host = '3750g'; my $t = new Net::Telnet (Timeout => 10, Prompt => '/3750G\>/', ); $t->open($host); $t->login($user,$pass); @data = $t->cmd("show clock"); print "data is @data"; $t->close;
Here is the output of the script: data is 19:21:11.575 UTC Tue Aug 21 2007 I hope you can add the Net::Telnet::Cisco module in the future. It greatly simplifies life if you have a bunch of these to keep track of.
  • Comment on Re^4: Can't get data from cisco router/switch when telnetting in via perl script.
  • Download Code