Answer the question
In order to leave comments, you need to log in
What's wrong with the perl script?
Help me finish the script
use Net::Telnet;
use IO::File;
open my ($ip) = (IPlist, "iplist" or die "can't open iplist: $!");
my ($username) = 'admin';
my ($passwd) = 'admin';
my ($ena)='enable';
my ($conf)='conf t';
my ($command1)='hostname R2D2';
my ($command2)='exit';
my ($command3)='wr mem';
$t = new Net::Telnet (Timeout => 10, Telnetmode => 1, Input_Log => "infile.log", Output_log => "output.log",);
$t->open("$lines");
$t->waitfor('/login:$/i');
$t->print($username);
$t->waitfor('/Password:$/i');
$t->print($passwd);
$t->print ("$ena");
$t->print ("$conf");
$t->print("$command1");
$t->print("$command2");
$t->print("$command3");
$t->print("$command2");
while (@ lines = "<IPlist>")
{
$t->open("$lines");
$t->waitfor('/login:$/i');
$t->print($username);
$t->waitfor('/Password:$/i');
$t->print($passwd);
$t->print ("$ena");
$t->print ("$conf");
$t->print("$command1");
$t->print("$command2");
$t->print("$command3");
$t->print("$command2");
}
close ( IPlist );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question