X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fnms.pm;fp=include%2Fnms.pm;h=0c0d7541be2371bcc6e9f280acbe41de85a584c6;hb=b672cfbe4808f8bea17c32311ab2442bb22407e5;hp=f895ffda4cbf06f6583b5e9c907429c5c893b763;hpb=9180f8278b332f8eb6c65a11d6f284f5facf6722;p=nms diff --git a/include/nms.pm b/include/nms.pm index f895ffd..0c0d754 100644 --- a/include/nms.pm +++ b/include/nms.pm @@ -44,4 +44,20 @@ sub switch_connect($) { return ($conn); } +# Send a command to switch and return the data recvied from the switch +sub switch_exec($$) { + my ($cmd, $conn) = @_; + + # Send the command and get data from switch + my @data = $conn->cmd($cmd); + my @lines = (); + foreach my $line (@data) { + # Remove escape-7 sequence + $line =~ s/\x1b\x37//g; + push (@lines, $line); + } + + return @lines; +} + 1;