From ben at blackavar.com Wed Oct 2 13:21:34 2002 From: ben at blackavar.com (Ben Boulanger) Date: Mon Aug 2 21:33:06 2004 Subject: [Nh-pm] Zoneedit autoupdate Message-ID: Howdy, After finding zoneedit's dynamic updating, I decided to write a perl script to auto update the records I host there whenever my IP address changes. The problem I had is that I use a linksys router to do NAT and give me wireless. So, after some noodling on it, I came up with this script to scrape the public IP address out of the linksys's Status page. I know that I'd heard of some folks using zoneedit on these lists, so I'm sending it around. Feel free to improve/comment. No warranty is given! Ben -- There are only 10 types of people in this world... those who understand binary, and those who don't. -------------- next part -------------- #!/usr/bin/perl -w use strict; use IO::Socket; # Define the hostnames to update at zoneedit my @hostnames = ( "mydomain.com", "mail.mydomain.com", "myotherdomain.com", "mail.myotherdomain.com", "www.myotherdomain.com", ); # zoneedit username my $username = "Username1"; # zoneedit password for above username my $password = "p455w0rd"; # location of the wget binary my $wget = "/usr/bin/wget"; # location of the file you would like to store the router's public IP address in my $router_ip_config = "/etc/router_pub_ip"; # password for the linksys, to do a screenscrape and grab the # current IP. Set linksys_in_use to 0 if you don't have one. my $linksys_in_use = 1; my $linksys_pw = "p455w0rd"; # we assume that the default GW is the linksys. # if this is incorrect, set it here: my $linksys_ip = ""; # get the linksys's current external IP address. my $router_cur_ip; if ($linksys_in_use) { $router_cur_ip = &linksys_scrape($linksys_pw, $linksys_ip); } else { # If you're not using a linksys, write your own function # here to retrieve the IP address of your external connection $router_cur_ip = 0; } # compare the linksys's current public IP with what we wrote down # last time. if ( -f $router_ip_config) { require $router_ip_config; } # if they're different, update the file containing the router's # public IP and then update zoneedit. if ($router_cur_ip ne $Config::router_pub_ip) { &update_router_pub_ip($router_cur_ip); &update_zoneedit(\@hostnames); } # Linksys scrape sub. This pulls the linksys's public IP address out of # the status page. This may need some tuning for firmware versions other # than 1.42.7 # Call this with linksys_scrape(linksys_pw, linksys_ip). If your default # gw is the linksys, no need for linksys_ip. sub linksys_scrape { my $linksys_pw = shift; my $linksys_ip = shift; ($linksys_ip = &get_default_gw) unless $linksys_ip; my $data = `$wget -O - --http-user=x --http-passwd=$linksys_pw 'http://$linksys_ip/Status.htm' 2>/dev/null`; $data =~ s/.*IP Address:<\/td>//; $data =~ s/<.*//; return $data; } # sub to get the default gateway. relies on netstat. sub get_default_gw { # get the output of netstat my @route_info_lines = split(/\n/, `netstat -rn`); # grab the last line (where the default gw hangs out) my $lastline = $route_info_lines[(scalar(@route_info_lines) - 1)]; # split the line into fields and take the second field. my $defgw = (split(/\s+/, $lastline))[1]; # return the default gw return $defgw; } # sub to update the config file that we store the default router IP # address in. sub update_router_pub_ip { my $new_ip = shift; # open (and clobber the old) file for writing open (RTRPUB, "+>$router_ip_config"); print RTRPUB "# This file contains your router (linksys, linux, whatever)'s\n", "# public IP Address. This is used by the dynamic updating program\n", "# you use to update zoneedit. Please do not edit this file unless\n", "# you're sure that you know what you're doing.\n", "package Config;\n", "\$router_pub_ip = \"$new_ip\";\n", "# Old Router pub IP: $Config::router_pub_ip\n", "1;"; close RTRPUB; } sub update_zoneedit { my $hostsref = shift; my @hosts = @$hostsref; # iterate over the hosts we defined at the top, updating each # with zoneedit's dynamic updating page. As we update each, # print a message saying so. This will allow cron to mail # the results of changes to root. foreach my $host (@hosts) { system("$wget -O /dev/null --http-user=$username --http-passwd=$password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=$host' 2>/dev/null"); print "$host updated to new IP: $router_cur_ip\n"; } } From pll at lanminds.com Mon Oct 7 10:43:37 2002 From: pll at lanminds.com (pll@lanminds.com) Date: Mon Aug 2 21:33:06 2004 Subject: [Nh-pm] TPJ in trouble Message-ID: <20021007154337.38C30F782@tater> Hi all, I just saw this on /., which surprised me, since I've been an avid fan and subscriber of The Perl Journal since issue #1!!! Anyway, if you're serious about Perl, or just really enjoy well written technical articles by very intelligent people, the TPJ is for you. Please subscribe if you are interested, or, if you just wish to help them out! http://www.tpj.com/ -- Seeya, Paul -- It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! From ben at blackavar.com Mon Oct 7 11:18:34 2002 From: ben at blackavar.com (Ben Boulanger) Date: Mon Aug 2 21:33:06 2004 Subject: [Nh-pm] TPJ in trouble In-Reply-To: <20021007154337.38C30F782@tater> Message-ID: On Mon, 7 Oct 2002 pll@lanminds.com wrote: > I just saw this on /., which surprised me, since I've been an avid > fan and subscriber of The Perl Journal since issue #1!!! Isn't the Perl Journal part of sysadmin? Is this breaking it off into its own magazine again, as it was awhile back? Ben -- A single conversation with a wise man is better than ten years of study. From pll at lanminds.com Mon Oct 7 11:52:51 2002 From: pll at lanminds.com (Paul Lussier) Date: Mon Aug 2 21:33:06 2004 Subject: [Nh-pm] TPJ in trouble In-Reply-To: Message from Ben Boulanger of "Mon, 07 Oct 2002 12:18:34 EDT." References: Message-ID: <20021007165251.BD8D2F782@tater> In a message dated: Mon, 07 Oct 2002 12:18:34 EDT Ben Boulanger said: >On Mon, 7 Oct 2002 pll@lanminds.com wrote: >> I just saw this on /., which surprised me, since I've been an avid >> fan and subscriber of The Perl Journal since issue #1!!! > >Isn't the Perl Journal part of sysadmin? Is this breaking it off into >its own magazine again, as it was awhile back? TPJ started out as an independant magazine, but then got taken over by Earthweb (I think) who some how fumbled the publishing. Sysadmin (under CMP) then took it over from Earthweb. For some reason CMP no longer wants to have sysadmin as a quarterly supplement of sysadmin. I'm not sure of the entire story here, but they are now looking for subscribers to fund the publishing. It looks like CMP is going to publish TPJ as an on-line, reader-supported-only publication, but in order to do so, they need to get a sufficient number of readers to at least make it profitable for them. Currently they only have about 800 subscribers, and they need 3000. Evidently they put the call out a while back to gain subscribers, but the /. article was the first I had heard about it. -- Seeya, Paul -- It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! From pll at lanminds.com Mon Oct 7 11:54:57 2002 From: pll at lanminds.com (Paul Lussier) Date: Mon Aug 2 21:33:07 2004 Subject: [Nh-pm] TPJ in trouble In-Reply-To: Message from Ben Boulanger of "Mon, 07 Oct 2002 12:18:34 EDT." References: Message-ID: <20021007165457.CA58CF782@tater> In a message dated: Mon, 07 Oct 2002 12:18:34 EDT Ben Boulanger said: >On Mon, 7 Oct 2002 pll@lanminds.com wrote: >> I just saw this on /., which surprised me, since I've been an avid >> fan and subscriber of The Perl Journal since issue #1!!! > >Isn't the Perl Journal part of sysadmin? Is this breaking it off into >its own magazine again, as it was awhile back? There's more information on the TPJ website: http://www.tpj.com/ Btw, a subscriptionis $12/year! -- Seeya, Paul -- It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! From morbus at disobey.com Mon Oct 7 12:17:41 2002 From: morbus at disobey.com (Morbus Iff) Date: Mon Aug 2 21:33:07 2004 Subject: [Nh-pm] TPJ in trouble In-Reply-To: <20021007154337.38C30F782@tater> Message-ID: <5.2.0.4.0.20021007131611.00a879e0@red.totalnetnh.net> >Anyway, if you're serious about Perl, or just really enjoy well >written technical articles by very intelligent people, the TPJ is for >you. Please subscribe if you are interested, or, if you just wish to >help them out! http://www.tpj.com/ I'd have to agree. I signed up the day of the announcement, both as a subscriber and a potential writer (an editor from Dr. Dobb's Journal emailed me a few weeks before the announcement asking if I wanted to write about Perl and OS X - so, if you want more NH/Perl love, subscribe! subscribe! ). -- Morbus Iff ( i'm the droid you're looking for ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ Please Me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus From cfarinella at appropriatesolutions.com Tue Oct 22 08:06:55 2002 From: cfarinella at appropriatesolutions.com (Charlie Farinella) Date: Mon Aug 2 21:33:07 2004 Subject: [Nh-pm] [Fwd: Fwd: Perl Quiz of the Week] Message-ID: <1035292015.9399.10.camel@lpc01.corp.appropriatesolutions.com> -----Forwarded Message----- > From: Paul Johnson > To: beginners@perl.org > Subject: Fwd: Perl Quiz of the Week > Date: 19 Oct 2002 14:12:32 +0200 > > I've not seen anyone mention this here, and it seems to be the sort of > thing that might be interesting to a fair few. The first quiz is in > full flow. > > ----- Forwarded message from Mark-Jason Dominus ----- > > > Date: Sat, 12 Oct 2002 22:32:19 -0400 > > From: Mark-Jason Dominus > > Subject: Perl Quiz of the Week > > To: clpm@lists.eyrie.org > > > > > > I taught a class in Illinois last week, and one of the students asked > > if there was a mailing list that would deliver a weekly Perl quiz or > > programming puzzle. I said I didn't know of one, but that it sounded > > like a good idea, and that I would set one up when I got back. > > > > I am now back. If you want to get the quiz-of-the-week, send a note > > to > > > > perl-qotw-subscribe@plover.com > > > > > > Please feel free to circulate this announcement to appropriate venues. > > > > Thanks. > > ----- End forwarded message ----- > > -- > Paul Johnson - paul@pjcj.net > http://www.pjcj.net > > -- > To unsubscribe, e-mail: beginners-unsubscribe@perl.org > For additional commands, e-mail: beginners-help@perl.org > > > -- ------------------------------------------------------------------------ Charlie Farinella, Appropriate Solutions, Inc. cfarinella@AppropriateSolutions.com 603-924-6079 From pll at lanminds.com Wed Oct 30 15:18:13 2002 From: pll at lanminds.com (pll@lanminds.com) Date: Mon Aug 2 21:33:07 2004 Subject: [Nh-pm] removing embedded hex from a text file? Message-ID: <20021030211813.9C61DF7E1@tater> Hi all, I have what's *supposed* to be a csv file dump of a spread sheet. However, when I print it out using perl, I see the chars in the file all over the place. When I look at it in hexl-mode in emacs, sure enough, those same characters are 0xa0. How can I easily replace those in a quick perl one-liner? I was originally trying to remove exess spaces, which is what lead me to discover these characters. I'm sure this is an obvious thing, but my brain isn't working well right now. I tried: perl -ane '$_ =~ s/0xA0//; print "$_\n";' file.csv But since 0xA0 is a character, not a string, this won't work. Thanks, -- Seeya, Paul -- It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! From meplists at earthlink.net Thu Oct 31 05:12:38 2002 From: meplists at earthlink.net (Mark Polhamus) Date: Mon Aug 2 21:33:07 2004 Subject: [Nh-pm] removing embedded hex from a text file? References: <20021030211813.9C61DF7E1@tater> Message-ID: <3DC11026.30503@earthlink.net> chr() converts a number to the corresponding character, and ord() converts it back. As in s/$c//go. (I bet there is a way to do that without the temporary var $c, but I can't find it right now). So: perl -p -e '$c = chr(0xA0); s/$c//go' (not tested) -- Mark Polhamus pll@lanminds.com wrote: > Hi all, > > I have what's *supposed* to be a csv file dump of a spread sheet. > However, when I print it out using perl, I see the chars in the > file all over the place. When I look at it in hexl-mode in emacs, > sure enough, those same characters are 0xa0. > > How can I easily replace those in a quick perl one-liner? I was > originally trying to remove exess spaces, which is what lead me to > discover these characters. > > I'm sure this is an obvious thing, but my brain isn't working well > right now. I tried: > > perl -ane '$_ =~ s/0xA0//; print "$_\n";' file.csv > > But since 0xA0 is a character, not a string, this won't work. > > Thanks,