/[cwmp]/google/tcli.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /google/tcli.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Sat May 19 15:15:14 2007 UTC (17 years ago) by dpavlin
File MIME type: text/plain
File size: 1244 byte(s)
initial import of cruft around TR-069

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
9 my $telnet = new Net::Telnet( $modem ) or die "Cannot telnet to $modem: $!\n";
10 my $exp = Expect->exp_init($telnet);
11
12 my ( $username, $password ) = ('Administrator','');
13 my $timeout = 15;
14
15 my $spawn_ok;
16 $exp->expect($timeout,
17 [
18 qr'login: $',
19 sub {
20 $spawn_ok = 1;
21 my $fh = shift;
22 $fh->send("$username\n");
23 exp_continue;
24 }
25 ],
26 [
27 'Password: $',
28 sub {
29 my $fh = shift;
30 print $fh "$password\n";
31 exp_continue;
32 }
33 ],
34 [
35 eof =>
36 sub {
37 if ($spawn_ok) {
38 die "ERROR: premature EOF in login.\n";
39 } else {
40 die "ERROR: could not spawn telnet.\n";
41 }
42 }
43 ],
44 [
45 timeout =>
46 sub {
47 die "No login.\n";
48 }
49 ],
50 '-re', qr'[#>:] $', #' wait for shell prompt, then exit expect
51 );

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26