/[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

Annotation of /google/tcli.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat May 19 15:54:04 2007 UTC (17 years ago) by dpavlin
File MIME type: text/plain
File size: 812 byte(s)
execute commands from file, comments supported in commands file
1 dpavlin 2 #!/usr/bin/perl -w
2    
3     use strict;
4     use Expect;
5     use Net::Telnet;
6    
7     my $modem = '192.168.1.254';
8 dpavlin 3 my @commands = (
9     ':system config led=flash',
10     );
11 dpavlin 2
12 dpavlin 4 while(<>) {
13     chomp;
14     next if (/^#/ || /^\s*$/);
15     push @commands, $_;
16     }
17    
18     push @commands, ':system config led=off';
19    
20 dpavlin 3 my $debug = 0;
21    
22 dpavlin 2 my $telnet = new Net::Telnet( $modem ) or die "Cannot telnet to $modem: $!\n";
23     my $exp = Expect->exp_init($telnet);
24 dpavlin 3 $exp->debug( $debug );
25 dpavlin 2
26 dpavlin 4 $exp->log_stdout( 1 );
27    
28 dpavlin 2 my ( $username, $password ) = ('Administrator','');
29 dpavlin 3 my $timeout = 10;
30 dpavlin 2
31 dpavlin 3 $exp->expect($timeout, 'Username : ');
32     $exp->send("$username\r\n");
33     $exp->expect($timeout, 'Password :');
34     $exp->send("$password\r\n");
35     $exp->expect($timeout, '=>');
36    
37     foreach my $cmd ( @commands ) {
38     $exp->send( "$cmd\r\n" );
39     $exp->expect($timeout, '=>');
40     }
41    
42 dpavlin 4 $exp->send( "exit\r\n" );
43     $exp->soft_close();
44    

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26