
parvees
Novice
Aug 21, 2012, 7:50 AM
Post #1 of 11
(2493 views)
|
|
extended login using perl script
|
Can't Post
|
|
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)
|