10 my $password = 'removed';
13 my $poll_frequency = 60;
15 # Send a command to switch and return the data recvied from the switch
17 my ($cmd, $conn) = @_;
19 # Send the command and get data from switch
20 my @data = $conn->cmd($cmd);
22 foreach my $line (@data) {
23 # Remove escape-7 sequence
24 $line =~ s/\x1b\x37//g;
31 sub switch_connect($) {
34 # Dump_Log => '/tmp/dumplog-queue',
35 my $conn = new Net::Telnet( Timeout => $timeout,
37 Prompt => '/(es3024|e\d+\-\dsw)>/i');
38 my $ret = $conn->open( Host => $ip);
39 if (!$ret || $ret != 1) {
42 # XXX: Just send the password as text, I did not figure out how to
43 # handle authentication with only password through $conn->login().
44 #$conn->login(»·Prompt => '/password[: ]*$/i',
46 # Password => $password);
47 $conn->cmd($password);
55 my $time = POSIX::ctime(time);
57 printf STDERR "[%s] %s\n", $time, $msg;
61 die("Error in arguments passed\n".
62 "./ssendfile.pl addr configfile\n");
65 my $conn = switch_connect($ARGV[0]);
66 if (!defined($conn)) {
67 die("Could not connect to switch.\n");
70 open(CONFIG, $ARGV[1]);
74 print "Executing: `$cmd`\n";
75 # if ($cmd =~ /ip ifconfig swif0 (\d{1-3}\.\d{1-3}\.\d{1-3}\.\d{1-3})/) {
76 # print "New ip: $1\n";
77 # $conn->cmd( String => $cmd,
79 # $conn = switch_connect($1);
80 # if (!defined($conn)) {
81 # die "Could not connect to new ip: $1\n";
85 my @data = switch_exec($cmd, $conn);
86 foreach my $line (@data) {
87 $line =~ s/[\r\n]+//g;