I have this script that I have hacked together and I can’t seem to get it to run.
The Net::Telnet::Cisco is giving me a big issue. It says that the package is installed, but how knows here is the code:
#!/usr/bin/perl
use Net::Ping;
$host = ‘111.111.111.111;
print “starting…”;
print “starting…”;
$counter = 0;
while ($counter <=4)
{
$p = Net::Ping->new(“icmp”, 2);
$counter++ unless $p->ping($host);
print “pinging…”;
if ($p->ping($host))
{ $counter = 0;
print “$host is alive.\n”;
}
sleep (10);
if ($counter = 3)
{
&noshut($counter);
print “$host is unreachable switching to ISDN.\n”;
}
}
$p->close();
sub noshut
{
use Net::Telnet::Cisco;
my $cs = Net::Telnet::Cisco->( Host => ‘192.168.0.1’ );
$cs->login( ‘pword’, ‘uname’ );
# Turn off paging
my @cmd_output = $cs->cmd( ‘terminal length 0’ );
# Execute a command
@cmd_output = $cs->cmd( ‘config t’ );
print @cmd_output;
@cmd_output = $cs->cmd( ‘int e1’ );
print @cmd_output;
@cmd_output = $cs->cmd( ‘shut’ );
print @cmd_output;
sleep (350);
print “sleeping…”;
@cmd_output = $cs->cmd( ‘noshut’ );
print @cmd_output;
$counter = 0;
return $counter;
$cs->close;
}
can anyone see the issue here?