Hi,

The below script works fine for me but with normal login, Actually i need to go with "enable 5" and with password "xxxx" to get the user details. So please any one help is here highly appreciated.

Here is my prompt for enable, Pleaes have look on it,
ERX02>enable 5
Password: **********
ERX02#

#!/usr/bin/perl
use Net::Telnet::Cisco;
#$rtrip = 'xx.xx.xx.xxx';
#$pass='support123';
sub juniperlogin
{
$rtrip = $_[0];

print "Logging into router $rtrip\n";

$session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30');

$session->login(Name => 'login', Password => 'support123', Prompt => '/ERX02>$/', Timeout => '30');

#$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30');
}
sub junipercmd
{
$cmd = $_[0];
#@output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60');
@output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60');
return @output;
}
&juniperlogin("1.1.7.1");

@output =&junipercmd("show version");
print @output;

Nobody here is going to debug your script. If it does not work describe what is not working and any error messages you get. Then maybe someone can try and help.

Nobody here is going to debug your script. If it does not work describe what is not working and any error messages you get. Then maybe someone can try and help.

The problem is i cannot loged in with "enable 5" and unable to excute the command. show privelige command, Here any one help is highly appreciated. thanks in advance

Up on runnig the below script i have the following message,

perl juni.pl
Name "main::Password" used only once: possible typo at juni.pl line 4.
Name "main::enableyes" used only once: possible typo at juni.pl line 15.
Logging into router 212.119.67.11
command timed-out at juni.pl line 17

Here is my prompt enable 5 prompt

ERX02>enable 5
Password: **********
ERX02#

#!/usr/bin/perl
use Net::Telnet::Cisco;
#$rtrip = '1.1.1.1';
$Password='support';
sub juniperlogin
{
$rtrip = $_[0];

print "Logging into router $rtrip\n";

$session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30');

$session->login(Name => 'login', Password => 'support', Prompt => '/ERX02>$/', Timeout => '30');

if (! $enableyes)
{
$session->cmd(String => "enable 5", Prompt => '/ERX02#,(?m:^\w+@[\w.-]+[>])/', Timeout => '30');

}


#$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30');
}
sub junipercmd
{
$cmd = $_[0];
#@output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60');
@output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60');
return @output;
}
&juniperlogin("1.1.1.1");

@output =&junipercmd("show privilege");
print @output;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.