[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

SSH v2 Perl script for Cisco devices

Asked by matcor9925 in Perl Programming Language, Network Management

Tags: Perl, NA

Hello,

I currently have a working perl script that connects to a CSV list of Cisco devices and excecutes commands. The problem I have is that some of the devices are SSHv1 and SSHv2 which are being skipped. I'm looking for a command example that will start an SSHv1 or SSHv2 session and execute commands if the Cisco device does not respond to telnet. Thank you in advance.

Here is an example of my working Telnet script:

<SNIP>
#!/usr/bin/perl
#

use Net::Telnet::Cisco;
use Term::ReadKey;

print "Router Reload v1.0\n
**Warning** This script will update the startup-config and schedule a reload for all devices listed in the reload file.\n
The reload will be scheduled for 8:00 GMT (3am EST, 2am CST, 1am MST, 12am PST).\n\n";
 
print "Enter username: ";
$user = <STDIN>;
chomp($user);

print "\n";

print "Enter password: ";
ReadMode('noecho');
$pass = ReadLine(0);
chomp($pass);

print "\n\n";

print "Enter filename. Example: reloads.year.month.day.csv\n";
ReadMode('normal');
$State = <STDIN>;
chomp($State);

open (INDB, "./$State") or
      die "cannot find file";
      
mkdir ("$State.logfiles");
mkdir ("$State.errors");

while (<INDB>)
      {
   $SiteData = $_;
    chomp ($StoreData);
($SiteNumber, $loopback, $reload, $copytftpst, $tftpserver, $configpath, $deststcfg, $deletevlan) = split (/,/, $SiteData);

my $CISCO_IP = "$loopback";
my $username = "$user";
my $password = "$pass";
my $enable_password = "$pass";
my $error = 'errorout';
my $loginerror = 'loginout';

my $session = Net::Telnet::Cisco->new(Host => $CISCO_IP, Input_log=> "$State.logfiles/$loopback.txt", Timeout=> '120', Errmode=> 'return');

unless($session) {
    #Do whatever error handling you want here
      print "Could not connect to Store# $StoreNumber device: $CISCO_IP\n\n\n";
      open ($error,">>./$State.errors/$loopback.txt");

            print $error "Could not connect to Store# $SiteNumber device: $CISCO_IP\n";

      close ($error);
      next;
}

$session->login($username, $password);

if($session->errmsg) {
open ($loginerror,">>./$State.errors/$loopback.txt");
print $loginerror "Authentication failed";
close ($loginerror);
      }

my @output = "";
my @host = "";

# Enable mode
if ($session->enable($enable_password) )
{
     @output = $session->cmd('show privilege');
     @host = $session->cmd('sho run | include hostname');
     print "@output for @host $loopback\n";
}
else
{
     warn "Can't enable: " . $session->errmsg;
}

$session->cmd("$reload\n");
$session->cmd("$copytftpst\n$tftpserver\n$configpath\n$deststcfg");
$session->cmd("$deletevlan\n\n");
print "$reload\n$deletevlan\n$copytftpst\n$tftpserver\n$configpath\n$deststcfg\n\n";
$session->close;

      }
</SNIP>
 
Related Solutions
Keywords: SSH v2 Perl script for Cisco devices
 
Loading Advertisement...
 
[+][-]11/13/08 12:55 PM, ID: 22954452Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/08 01:08 PM, ID: 22954594Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/08 03:36 PM, ID: 22955984Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/08 08:28 AM, ID: 22961001Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/14/08 11:02 AM, ID: 22962470Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/08 01:14 PM, ID: 22963745Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/14/08 09:14 PM, ID: 22965884Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/08 07:40 AM, ID: 22976297Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/17/08 08:10 AM, ID: 22976632Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/17/08 02:17 PM, ID: 22980131Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/17/08 02:36 PM, ID: 22980300Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Perl Programming Language, Network Management
Tags: Perl, NA
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 1
Solution Grade: B
 
[+][-]12/09/08 06:43 PM, ID: 23135874Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_2_20070628