X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=scripts%2Ftcli.pl;h=eede562809390bd51bfcf91a3e59f98289bd7168;hb=ffcc3a1a6f8e4169402bc180e043b8715de73187;hp=162a4b4435a3e9691bbc1f1a48d978bfc8243113;hpb=4cfba3ff18c39f8a227807a90e6ba5e27e34faad;p=perl-cwmp.git diff --git a/scripts/tcli.pl b/scripts/tcli.pl index 162a4b4..eede562 100755 --- a/scripts/tcli.pl +++ b/scripts/tcli.pl @@ -3,16 +3,35 @@ use strict; use Expect; use Net::Telnet; +use Data::Dump qw/dump/; + +my $modem = '10.0.0.138'; +$modem = shift @ARGV if $#ARGV > 1; -my $modem = '192.168.1.254'; my @commands = ( ':system config led=flash', ); +warn "ARGV = ",dump( $ARGV ); + +sub ask { + my ( $prompt, $default ) = @_; + warn "## ask $prompt [default]"; + print "$prompt [$default] "; + my $in = ; + chomp($in); + $in = $default unless length($in) > 1; + return $in; +} + while(<>) { chomp; next if (/^#/ || /^\s*$/); - push @commands, $_; + my $l = $_; + warn "--$_--"; + $l =~ s/ask\(([^|\)]+)(?:\|([^\)]+))?\)/ask($1,$2)/eg; + warn "++ $l\n"; + push @commands, $l; } push @commands, ':system config led=off';