+# Send a command to switch and return the data recvied from the switch
+sub switch_exec {
+ my ($cmd, $conn, $print) = @_;
+
+ # Send the command and get data from switch
+ my @data;
+ if (defined($print)) {
+ $conn->print($cmd);
+ return;
+ } else {
+ @data = $conn->cmd($cmd);
+ }
+ my @lines = ();
+ foreach my $line (@data) {
+ # Remove escape-7 sequence
+ $line =~ s/\x1b\x37//g;
+ push (@lines, $line);
+ }
+
+ return @lines;
+}
+