X-Git-Url: http://git.rot13.org/?p=perl-cwmp.git;a=blobdiff_plain;f=scripts%2Ftcli.pl;h=45456e3f3e75bd3b1e4a8cb93822b0ef252f54a4;hp=eede562809390bd51bfcf91a3e59f98289bd7168;hb=7e8f73a25240010637c0076678b8e140fd8c06c4;hpb=6e3645ccbae50d7776645f07f5f70b785a0bec84 diff --git a/scripts/tcli.pl b/scripts/tcli.pl index eede562..45456e3 100755 --- a/scripts/tcli.pl +++ b/scripts/tcli.pl @@ -5,15 +5,17 @@ use Expect; use Net::Telnet; use Data::Dump qw/dump/; +die "usage: $0 [modem] commands\n" unless @ARGV; + my $modem = '10.0.0.138'; -$modem = shift @ARGV if $#ARGV > 1; +$modem = shift @ARGV if $#ARGV >= 1; + +my $debug = 0; my @commands = ( ':system config led=flash', ); -warn "ARGV = ",dump( $ARGV ); - sub ask { my ( $prompt, $default ) = @_; warn "## ask $prompt [default]"; @@ -28,15 +30,15 @@ while(<>) { chomp; next if (/^#/ || /^\s*$/); my $l = $_; - warn "--$_--"; + warn "--$_--" if $debug; $l =~ s/ask\(([^|\)]+)(?:\|([^\)]+))?\)/ask($1,$2)/eg; - warn "++ $l\n"; + warn "++ $l\n" if $debug; push @commands, $l; } push @commands, ':system config led=off'; -my $debug = 0; +warn "## connecting to $modem\n"; my $telnet = new Net::Telnet( $modem ) or die "Cannot telnet to $modem: $!\n"; my $exp = Expect->exp_init($telnet);