X-Git-Url: http://git.rot13.org/?p=perl-cwmp.git;a=blobdiff_plain;f=scripts%2Ftcli.pl;fp=scripts%2Ftcli.pl;h=eede562809390bd51bfcf91a3e59f98289bd7168;hp=e3786c3e51caf94248aa4b8c13eff40a408819ab;hb=6e3645ccbae50d7776645f07f5f70b785a0bec84;hpb=5466e6a4b964a23fcae743c5af6429f5881b3f37 diff --git a/scripts/tcli.pl b/scripts/tcli.pl index e3786c3..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 @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';