From 40a5eac8eef8902e38220af6192c4a9f384cba35 Mon Sep 17 00:00:00 2001 From: "Eirik A. Nygaard" Date: Tue, 3 Apr 2007 10:19:19 +0200 Subject: [PATCH] Some zyxelng-magic, set a new ip and add the config to the zyxel, no saving. --- clients/zyxelng.pl | 91 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/clients/zyxelng.pl b/clients/zyxelng.pl index e46f0fb..614838d 100644 --- a/clients/zyxelng.pl +++ b/clients/zyxelng.pl @@ -5,13 +5,96 @@ use strict; use lib '../include'; -use nms; +use nms qw(switch_connect switch_exec); use ios; +#my $t = nms::ios_connect('62.148.36.12', 'c', 'c', 'c'); -my $t = nms::ios_connect('62.148.36.12', 'c', 'c', 'c'); +#print STDERR "No such network 192.168.1.0\n" if nms::ios_getroute($t, "192.168.1.0") == 0; -print STDERR "No such network 192.168.1.0\n" if nms::ios_getroute($t, "192.168.1.0") == 0; +#nms::ios_close($t); -nms::ios_close($t); +my $one = 1; + +my $switchip; +$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); + +my $cmds1 = <close(); + +my $cmd; +$cmd = "ip ifconfig swif0 192.168.1.1/24" if $one; +$cmd = "ip ifconfig swif0 192.168.2.150/24" unless $one; +print "Sending '$cmd'\n"; +my $pid = fork(); +if ($pid == 0) { + switch_exec($cmd, $switch); + exit 0; +} else { + print "Sleeping...\n"; + sleep 1; +} +$switch->close(); +print "Reconnecting... "; +$switchip = "192.168.1.1" if $one; +$switchip = "192.168.2.150" unless $one; +do { + print "Connecting to: $switchip\n"; + $switch = switch_connect($switchip); + + print (defined($switch)? $switch : "foo") ." <---- switch\n"; + if (defined($switch) || $switch) { + last; + } + print "."; + sleep 1; +} while (1); +print "\n"; + +print $switch."\n"; +$cmd = "sys sw vlan1q svlan cpu 248"; +print "Sending '$cmd'\n"; +switch_exec($cmd, $switch, 1); -- 2.39.2