=================================================================== RCS file: /cvs/trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2005/12/30 20:26:41 1.4 +++ trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2006/01/03 00:22:19 1.5 @@ -1,5 +1,5 @@ package Net::Telnet::Trango; -# $RedRiver: Trango.pm,v 1.3 2005/12/30 19:26:06 andrew Exp $ +# $RedRiver: Trango.pm,v 1.4 2005/12/30 20:26:41 andrew Exp $ use strict; use warnings; use base 'Net::Telnet'; @@ -257,8 +257,8 @@ sysinfo => { decode => 'all', expect => $success }, updateflash => { decode => 'all', expect => $success }, sulog => { decode => 'sulog', expect => $success }, - 'exit' => { Prompt => '//', cmd_disconnects => 1 }, - reboot => { Prompt => '//', cmd_disconnects => 1 }, + 'exit' => { no_prompt => 1, cmd_disconnects => 1 }, + reboot => { no_prompt => 1, cmd_disconnects => 1 }, #su password??? #_bootloader #temp @@ -279,6 +279,7 @@ login_banner Timeout last_lines + last_vals ); sub AUTOLOAD @@ -405,6 +406,78 @@ =pod +=item su_password + +C + +=cut + +sub su_password +{ + my $self = shift; + my $su = shift || '!'; + my $new_pass = shift || ''; + + unless (defined $su) { + warn "No su passed!" + #return undef; + } + + unless (defined $new_pass) { + warn "No new password!" + #return undef; + } + + return $self->cmd(String => 'su password ' . + $su . ' ' . + $new_pass . ' ' . + $new_pass, + expect => $success, + ); +} + + +=pod + +=item sudb_view + +returns a reference to an array of hashes each containing: + + suid + type + cir + mir + mac + +=cut + +sub sudb_view +{ + my $self = shift; + + my @lines = $self->cmd( String => 'sudb view', expect => $success ); + + return undef unless @lines; + + my @sus; + foreach (@lines) { + if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9a-fA-F]+)/) { + my %s = ( + suid => $1, + type => $2, + cir => $3, + mir => $4, + mac => $5, + ); + push @sus, \%s; + } + } + + return \@sus; +} + +=pod + =item enable_tftpd runs C 'on')> and makes sure that Tftpd is now 'listen'ing @@ -523,7 +596,13 @@ if ($cfg{'args'}) { $cmd{'String'} .= ' ' . $cfg{'args'}; } - my @lines = $self->SUPER::cmd(%cmd); + my @lines; + unless ($cfg{'no_prompt'}) { + @lines = $self->SUPER::cmd(%cmd); + } else { + $self->print($cmd{'String'}); + @lines = $self->lastline; + } $self->last_lines(\@lines); @@ -537,6 +616,8 @@ $vals = _decode_lines(@lines); } } + + $self->last_vals($vals); my $last = $self->lastline;