]> git.sesse.net Git - nms/blobdiff - include/nms.pm
Move switch_exec() into nms.pm.
[nms] / include / nms.pm
index f895ffda4cbf06f6583b5e9c907429c5c893b763..0c0d7541be2371bcc6e9f280acbe41de85a584c6 100644 (file)
@@ -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;