Re: [ILUG] Internet Setup Script

From: Peter Heslin (Peter.Heslin at domain ucd.ie)
Date: Fri 04 Feb 2000 - 18:36:36 GMT


On Fri, Feb 04, 2000 at 12:02:48AM +0000, Ross Lynch wrote:
> Hey,
>
> Well, I've made some modifications to the script (ie. got it working)
> and translated it to PERL too. It works fine now, and new ISP's are easy
> to add.

Can I make a few suggestions about this code without sounding like an
ungrateful ass?

<pedant mode="teacher">

I can tell you from personal experience that it is a nightmare to
support a Perl script that does not check the success of /all/ system
calls. If Perl cannot open the file you want, it will run merrily on
without so much as a whisper, only to fail at a later stage when you
rely upon the existance of the filehandle you think you got earlier.
People will e-mail you with reports of your script throwing an exception
miles away from and seemingly unrelated to the actual problem, which
becomes a nightmare to figure out. So do it like this:

open (RESOLV, ">>/etc/resolv.conf")
                                        or die "Couldn't open resolv.conf: $!";

Also, what is going to happen to the length of this file if this
script is run again and again? You might want to check for the
preexistance of the lines you are going to append.

A more general issue is that you might always want to catch all if ...
elsif blocks with a final else. Otherwise a user that enters `?'
instead of `y' or `n' may get bizzare results, which will be reported
back to you in cryptic ways.

You could make it even easier to add new ISP's if you were to abstract
all of the ISP-specific data out of the code, and put it in a __DATA__
block at the end, but that may be more work than you want to do on this
quickie.

How about checking for the existance of /dev/modem before prompting for
a serial port? You might look at the way wvdial handles this issue,
which is very cool.

</pedant>

Thanks for this; I still have not managed to get Surf No Limits working
properly for me, so I am in no position to comment on the technical
stuff. 8^)

I am off now to see if I have caller-id disabled! (or should I have it
enabled? Oh well ...)

Peter



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:05:21 GMT