> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:gkhgkh@;attbi.com] 
> Sent: Friday, November 15, 2002 3:12 PM
> To: [EMAIL PROTECTED]
> Subject: Remotely Change Def GW on Win32
> 
> 
> Does anyone know of a way to change the def gw remotely using perl?
> 
> Thanks in advance.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

I actually just wrote a script to do this sort of thing.  The key is the
"route" statement on the command line.

It's my first Perl script -- be kind. :)

#!\Perl\bin\
# A perl script to force failover between our Internet providers.
# Written by:   Charlotte Oliver
# Date:         October 22, 2002

while (1==1) {                                  # Start while loop
$IP = <munged number>
$output = `ping -n 3 $IP`                       # Run a ping test and
store results
if ($output="Request timed out."); {    # Change the gateway and IP of
the external NIC to the Netopia.
        print "WCOM T-1 is down. \n";
        print "Initializing Covad DSL backup. \n ";
        $cmd1 == `route delete 0.0.0.0`, `route add 0.0.0.0 mask
255.255.254.0 10.32.0.5`,`route add 0.0.0.0 mask 0.0.0.0 10.32.0.5`;

Return the T-1 to service.
        while ($output="Request timed out.") {
                $output2 = `ping -n 3 $IP`      
                if ($output2="Reply from $IP"); {
                print "WCOM T-1 has returned to service.";      
                print "Initializing WCOM T-1.";
                $cmd2 == `route delete 0.0.0.0`, `route add 0.0.0.0 mask
255.255.254.0 10.32.0.1`, `route add 0.0.0.0 mask 0.0.0.0 10.32.0.1`
                }                       # End if statement
        }                               # End nested while loop 
}                                       # End if statement
}                                       # End controlling while loop

Cheers,
Charlotte

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to