-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;
-}
-
-sub switch_connect {
- my ($ip) = @_;
-
- my $conn = new Net::Telnet( Timeout => $timeout,
- Dump_Log => '/tmp/dumplog',
- Errmode => 'return',
- Prompt => '/(es3024|e\d+\-\dsw)>/i');
- my $ret = $conn->open( Host => $ip);
- if (!$ret || $ret != 1) {
- return (0);
- }
- # XXX: Just send the password as text, I did not figure out how to
- # handle authentication with only password through $conn->login().
- #$conn->login( Prompt => '/password[: ]*$/i',
- # Name => $password,
- # Password => $password);
- my @data = $conn->cmd($password);
- # Get rid of banner
- $conn->get;
- return ($conn);
-}
-
-