CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: extended login using perl script: Edit Log



parvees
Novice

Aug 21, 2012, 7:50 AM


Views: 3386
extended login using perl script

Hi i have one server from where i login to all my network devices to execute command. I need to execute some commands on daily basis on all network device (show processes cpu history and show log) , after loggin in to the terminal server and from their accessing individual network devices.

i wrote the script to access the terminal server and it is successful but how to login to all the network devices from there and execute the command i have no clue. i am newbie in the scripting field and hence any suggestion is highly appreciate.

following is the .pl for login in to terminal server

#!/usr/bin/perl
use Net::SSH2;
use warnings;
use strict;

@servers = ("EGHQ-PR-1","EGHQ-PR-2","PR-1","PR-2");
my $host = "taco";
my $user = "s******";
my $password = "s****";

my $ssh = Net::SSH2->new();

if(!$ssh->connect($host)){
print("Connection Failed\n");
exit(1);
}

if(!$ssh->auth_password($user,$password)){
print("Authentication Failed");
exit(1);
}

my $channel = $ssh->channel();
my $command = $channel->exec("nslookup taco") or die $_;
my $output;
my $len = $channel->read($output,2048);
print "output is $output\n";

it works fine.

please assist how to proceed from here.

thanks,
PSM


(This post was edited by parvees on Aug 21, 2012, 9:15 AM)


Edit Log:
Post edited by parvees (Novice) on Aug 21, 2012, 9:15 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives