[Techtalk] Perl tutorials

Michelle Murrain tech at murrain.net
Tue Oct 22 21:50:40 EST 2002


At 3:32 PM -0400 10/22/02, Charlotte Oliver wrote:
>Heya folks --
>
>I am going to write a script that will send out pings and, if a ping
>fails to return, change the default IP and gateway of a box.  The idea
>behind this is that if our T1 dies, our DSL line will take over without
>any additional network equipment.  The box itself is Windows NT 4.0
>(bleh, but it's what we run) and I've figured out how to change the
>gateway and IP (route del and route add) sucessfully.  The part I'm not
>sure about is the interpretation of a ping.
>
>I'm guessing that Perl would be a good language for this and I see that
>Perl is available on a Windows platform.  I'm told it doesn't work well
>on a NT platform, but I'm building a testbox to find out if this is true
>or not.  I've some experience with C and bash scripts, but no other
>serious programming experience.  This is the pseudocode I came up with
>to try and attempt this:
>
>Start
>ping T1_ip
>read $output
>If $output = "Destination not reachable",
>	route del  0.0.0.0 mask 255.255.254.0  T1_IP
>	route del  0.0.0.0 mask 0.0.0.0        T1_IP
>	route add  0.0.0.0 mask 255.255.255.0  DSL_IP
>	route add  0.0.0.0 mask 0.0.0.0	   DSL_IP
>else
>	{Null}
>fi
>Stop
>
>Does anyone have further suggestions or URLs of good online tutorials?
>Are there other thoughts on whether or not this is a good solution for
>network design?

I did a script that did the ping check and kept a log - it didn't do 
any network changes. Unfortunately, I can't seem to find that script, 
but it was basically the same as your psuedocode suggests. I think 
it's a fine approach, and perl is a great language for stuff like 
this. There is a whole book on network programming with perl - but 
you really don't need that to get this done.

There are the Learning Perl books - which are a great start.
-- 
.Michelle

--------------------------
Michelle Murrain, Technology Consulting
tech at murrain.net     http://www.murrain.net
413-253-2874 ph
413-222-6350 cell
413-825-0288 fax
AIM:pearlbear0 Y!:pearlbear9 ICQ:129250575

"A vocation is where the world's hunger & your great gladness meet."  
Frederick Buechner




More information about the Techtalk mailing list