1 |
#!/usr/bin/perl -w |
2 |
|
3 |
use strict; |
4 |
use Expect; |
5 |
use Net::Telnet; |
6 |
|
7 |
my $modem = '192.168.1.254'; |
8 |
my @commands = ( |
9 |
':system config led=flash', |
10 |
':system config led=red', |
11 |
':system config led=off', |
12 |
'exit', |
13 |
); |
14 |
|
15 |
my $debug = 0; |
16 |
|
17 |
my $telnet = new Net::Telnet( $modem ) or die "Cannot telnet to $modem: $!\n"; |
18 |
my $exp = Expect->exp_init($telnet); |
19 |
$exp->debug( $debug ); |
20 |
|
21 |
my ( $username, $password ) = ('Administrator',''); |
22 |
my $timeout = 10; |
23 |
|
24 |
my $spawn_ok; |
25 |
$exp->expect($timeout, 'Username : '); |
26 |
$exp->send("$username\r\n"); |
27 |
$exp->expect($timeout, 'Password :'); |
28 |
$exp->send("$password\r\n"); |
29 |
$exp->expect($timeout, '=>'); |
30 |
|
31 |
foreach my $cmd ( @commands ) { |
32 |
warn "sending >> $cmd\n"; |
33 |
$exp->send( "$cmd\r\n" ); |
34 |
$exp->expect($timeout, '=>'); |
35 |
} |
36 |
|