=================================================================== RCS file: /cvs/trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2006/06/29 01:39:52 1.8 +++ trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2006/07/14 02:17:29 1.9 @@ -1,5 +1,5 @@ package Net::Telnet::Trango; -# $RedRiver: Trango.pm,v 1.7 2006/06/28 22:33:18 andrew Exp $ +# $RedRiver: Trango.pm,v 1.8 2006/06/29 00:39:52 andrew Exp $ use strict; use warnings; use base 'Net::Telnet'; @@ -49,6 +49,11 @@ Same as new from L but has defaults for the trango 'Prompt' +It also takes an optional parameter 'Decode'. If not defined it +defaults to 1, if it is set to 0, it will not decode the output and +instead return an array of the lines that were returned from the +command. + =cut sub new @@ -67,6 +72,8 @@ foreach my $key (keys %args) { $PRIVATE{$key} = $args{$key}; } + $PRIVATE{'Decode'} = 1 unless defined $PRIVATE{'Decode'}; + delete $args{'Decode'}; my $self = $class->SUPER::new(%args); bless $self if ref $self; @@ -247,6 +254,22 @@ returns true on success, undef on failure +=item syslog + +returns the output from the syslog command + +=item pipe + +returns the output from the pipe command + +=item maclist + +returns the output from the maclist command + +=item eth_list + +returns the output from the eth list command + =cut @@ -260,6 +283,11 @@ 'exit' => { no_prompt => 1, cmd_disconnects => 1 }, reboot => { no_prompt => 1, cmd_disconnects => 1 }, save_sudb => { String => "save sudb", expect => $success }, + syslog => { expect => $success }, + 'pipe' => { }, # XXX needs a special decode + maclist => { }, # XXX needs a special decode and a special expect + eth_link => { String => "eth link", expect => $success }, + # eth r, w and reset??? #su password??? #_bootloader #temp @@ -437,7 +465,6 @@ ); } - =pod =item sudb_view @@ -460,8 +487,13 @@ return undef unless @lines; + unless ($PRIVATE{'Decode'}) { + return @lines; + } + my @sus; foreach (@lines) { + next unless $_; if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) { my %s = ( suid => $1, @@ -571,7 +603,6 @@ return $self->cmd( String => 'sudb delete ' . $suid, expect => $success ); } - =pod =item sudb_modify @@ -701,9 +732,9 @@ ); my %cfg; - if (@_ == 2) { + if (@_ == 1) { $cfg{'String'} = shift; - } elsif (@_ > 2) { + } elsif (@_ > 1) { %cfg = @_; } @@ -748,7 +779,7 @@ $self->last_lines(\@lines); my $vals = 1; - if ($cfg{'decode'}) { + if ($PRIVATE{'Decode'} && $cfg{'decode'}) { if ($cfg{'decode'} eq 'each') { $vals = _decode_each_line(@lines); } elsif ($cfg{'decode'} eq 'sulog') { @@ -770,7 +801,7 @@ $self->is_connected(0); } - if ($cfg{'decode'}) { + if ($PRIVATE{'Decode'} && $cfg{'decode'}) { return $vals; } else { return @lines;