]> git.sesse.net Git - nms/commitdiff
More zyxelng fixes.
authorEirik A. Nygaard <eirikald@pvv.ntnu.no>
Tue, 3 Apr 2007 12:41:53 +0000 (14:41 +0200)
committerEirik A. Nygaard <eirikald@pvv.ntnu.no>
Tue, 3 Apr 2007 12:41:53 +0000 (14:41 +0200)
clients/zyxelng.pl

index 614838d56ea977e08e8ca9e1e709004ebbca0b5a..c6a0b1ef8fb0ea49f2d0bca7b3c146a14f9b7abb 100644 (file)
@@ -5,6 +5,8 @@
 use strict;
 use lib '../include';
 
+use Data::Dumper;
+
 use nms qw(switch_connect switch_exec);
 use ios;
 
@@ -14,11 +16,11 @@ use ios;
 
 #nms::ios_close($t);
 
-my $one = 1;
+my $one = 0;
 
 my $switchip;
-$switchip = "87.76.250.226" if $one;
-#$switchip = "192.168.2.150" if $one;
+#$switchip = "87.76.250.226" if $one;
+$switchip = "192.168.2.150" if $one;
 $switchip = "192.168.1.1" unless $one;
 my $switch = switch_connect($switchip);
 
@@ -62,7 +64,6 @@ foreach (split(/\n+/, $cmds1)) {
        print "Sending: '$_'\n";
        switch_exec($_, $switch);
 }
-$switch->close();
 
 my $cmd;
 $cmd = "ip ifconfig swif0 192.168.1.1/24" if $one;
@@ -70,9 +71,11 @@ $cmd = "ip ifconfig swif0 192.168.2.150/24" unless $one;
 print "Sending '$cmd'\n";
 my $pid = fork();
 if ($pid == 0) {
+       print "Sending ifconfig.. $cmd\n";
        switch_exec($cmd, $switch);
        exit 0;
 } else {
+       #switch_exec($cmd, $switch, 1);
        print "Sleeping...\n";
        sleep 1;
 }
@@ -80,21 +83,27 @@ $switch->close();
 print "Reconnecting... ";
 $switchip = "192.168.1.1" if $one;
 $switchip = "192.168.2.150" unless $one;
-do {
-       print "Connecting to: $switchip\n";
+autoflush STDOUT 1;
+print "Connecting to: $switchip...\n";
+my $i = 1;
+while(1) {
        $switch = switch_connect($switchip);
        
-       print (defined($switch)? $switch : "foo") ." <---- switch\n";
+       #print (defined($switch)? $switch : "foo") ." <---- switch\n";
        if (defined($switch) || $switch) {
                last;
        }
-       print ".";
+       printf("Waited $i seconds...\r");
+       $i++;
        sleep 1;
-} while (1);
+}
 print "\n";
 
 print $switch."\n";
 $cmd = "sys sw vlan1q svlan cpu 248";
 print "Sending '$cmd'\n";
+#print "XXX: No we did not...";
+#print Dumper($switch->cmd("ip ifconfig"));
+#print Dumper($switch->cmd("ip route status"));
 switch_exec($cmd, $switch, 1);
-
+$switch->close();