From david at cloudgraphics.com Tue Jun 7 18:51:34 2005 From: david at cloudgraphics.com (David Heayn) Date: Tue, 7 Jun 2005 21:51:34 -0400 Subject: [LA.pm] playing with perl fire Message-ID: Recently I thought it would be a good idea to circumvent the proxy blocker at work that disallows web browsing of "questionable" sites. So I built a very simple LWP mirroring script which works really well. However, my little hack has a shortcoming, the pictures are still being pulled off the "questionable" site and are blocked. My question to the group is if there is a technique/library/method to grab those remote images, save it to a temp directory, then swap out the HTML tags referencing the local files instead of the remote ones. You're more than welcome to play with my work in progress: http://www.cloudgraphics.com/cgi-bin/url.cgi And here's the source code (mostly ripped off the 'net) #!/usr/local/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); warningsToBrowser(1); use lib qw( ..); use HTML::TableExtract; use LWP::Simple; use Data::Dumper; my $cgi = "http://www.cloudgraphics.com/cgi-bin/url.cgi"; my $version = "Grabber v 1.0"; if (param('url')) { print header, start_html('NET Grabber'), my $url = param('url'); use LWP::Simple; my $baseurl = $url; my ($http, $oo, $base) = split (/\//, $baseurl); my $content = get $url; $content =~ s/href=\"http:\/\//href=\"$cgi\?url=http:\/\//ig; $content =~ s/href=\"\//href=\"$cgi\?url=$url/ig; $content =~ s/href='\//href='http:\/\/$base\//ig; $content =~ s/href=\//href=http:\/\/$base\//ig; print $content; end_html; } else { print header, start_html('NET Grabber'), h1('URL Grabber'), hr; print startform; print textfield(-name=>'url', -value=>'http://', -size=>60); print submit(-name=>'action', value=>'Process'), end_form; hr, end_html; } Cheers! David Heayn * http://www.cloudgraphics.com * 213/925.3283 From geoff at modperlcookbook.org Tue Jun 7 21:18:53 2005 From: geoff at modperlcookbook.org (Geoffrey Young) Date: Wed, 08 Jun 2005 00:18:53 -0400 Subject: [LA.pm] playing with perl fire In-Reply-To: References: Message-ID: <42A671AD.5070207@modperlcookbook.org> David Heayn wrote: > Recently I thought it would be a good idea to circumvent the proxy > blocker at work that disallows web browsing of "questionable" sites. I wrote this perl implementation of a "questionable" site circumvention tool a _long_ time ago, based on an article in 2600. IIRC the article explained how it worked and presented the code in lisp. I'm sure you could implement some dns lookups, etc, to make it fit your needs. in fact, when I showed it to a friend he programmed some windows thing that interfaced with msie, so all you did was type in the url you wanted in a toolbar and ie opened the appropriate back-door url. but I don't use windows, so... --Geoff #!/usr/bin/perl # usage: perl quad.pl 66.94.230.49 use strict; use Math::BigInt; my $binstring = join '', map { sprintf "%08b", $_ } split /\./, $ARGV[0]; my $decstring = Math::BigInt->new(0); my $exp = length($binstring); foreach my $i (1 .. $exp) { $decstring += substr($binstring, $i-1, 1) * (2 ** ($exp - $i)); } (my $result = `host $ARGV[0]`) =~ m/name pointer\s+(.*)/; print "http://$decstring would bring you to $1\n"; From RNathan at baxglobal.com Wed Jun 8 12:25:20 2005 From: RNathan at baxglobal.com (Ranga Nathan) Date: Wed, 8 Jun 2005 12:25:20 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm Message-ID: I have a need to run a script when a file is received into a directory via FTP. This is Linux SuSE9 environment. I am looking at Event.pm documentation. Can some one show me examples of how to monitor a directory for new files? If there are other elegant methods I would like to know. As a last resort, I can hand-roll one. But why re-invent the wheel? __________________________________________ Ranga Nathan / CSG Systems Programmer - Specialist; Technical Services; BAX Global Inc. Irvine-California Tel: 714-442-7591 Fax: 714-442-2840 From clay at panix.com Wed Jun 8 12:38:15 2005 From: clay at panix.com (Clay Irving) Date: Wed, 08 Jun 2005 12:38:15 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: References: Message-ID: <42A74927.2030704@panix.com> Ranga Nathan wrote: >I have a need to run a script when a file is received into a directory via >FTP. This is Linux SuSE9 environment. >I am looking at Event.pm documentation. Can some one show me examples of >how to monitor a directory for new files? >If there are other elegant methods I would like to know. > >As a last resort, I can hand-roll one. But why re-invent the wheel? > > I don't think I understand what you are trying to do -- Are you trying to do something that "find" or "if (-e $filename)" can't do for you? From RNathan at baxglobal.com Wed Jun 8 12:53:45 2005 From: RNathan at baxglobal.com (Ranga Nathan) Date: Wed, 8 Jun 2005 12:53:45 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: <42A74927.2030704@panix.com> Message-ID: __________________________________________ Ranga Nathan / CSG Systems Programmer - Specialist; Technical Services; BAX Global Inc. Irvine-California Tel: 714-442-7591 Fax: 714-442-2840 Clay Irving Sent by: losangeles-pm-bounces at pm.org 06/08/2005 12:38 PM To losangeles-pm at mail.pm.org cc Subject Re: [LA.pm] Monitoring a directory using Event.pm Ranga Nathan wrote: >I have a need to run a script when a file is received into a directory via >FTP. This is Linux SuSE9 environment. >I am looking at Event.pm documentation. Can some one show me examples of >how to monitor a directory for new files? >If there are other elegant methods I would like to know. > >As a last resort, I can hand-roll one. But why re-invent the wheel? > > I don't think I understand what you are trying to do -- Are you trying to do something that "find" or "if (-e $filename)" can't do for you? The host is receiving files continuously via FTP. As soon as the file is receive it needs to be processed by a script and the file moved to a 'processed' directory. Currently we have a script that runs under xinetd. It loops, sleeping for 30 seconds after processing the files. I want to make it event based. That is the script should run only WHEN the file appears as a result of FTP, essentially turning a batch type process into event-based processing. _______________________________________________ Losangeles-pm mailing list Losangeles-pm at pm.org http://mail.pm.org/mailman/listinfo/losangeles-pm From ofer at netapt.com Wed Jun 8 13:10:59 2005 From: ofer at netapt.com (Ofer Nave) Date: Wed, 8 Jun 2005 13:10:59 -0700 (PDT) Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: Message-ID: I'm no expert, so I could be wrong, but to my knowledge: The Event module, unfortunately, has nothing to do with this. What you want is an event-based filesystem, where modifications can trigger actions. The standard linux file system doesn't do this. There are some groovy new FSs that do this, but you probably don't want to go that route. Although it seems brute force, then best solution is probably write your script as daemon (run in the background continuously) and have it continuously look for new files to appear (sleep 1 in a loop or something). If you're heart is dead set on making this event driven, then make your daemon listen on a port, and modify your client-side code so that it connects to that port and sends a message after FTPing the file. -ofer On Wed, 8 Jun 2005, Ranga Nathan wrote: > I have a need to run a script when a file is received into a directory via > FTP. This is Linux SuSE9 environment. > I am looking at Event.pm documentation. Can some one show me examples of > how to monitor a directory for new files? > If there are other elegant methods I would like to know. > > As a last resort, I can hand-roll one. But why re-invent the wheel? > __________________________________________ > Ranga Nathan / CSG > Systems Programmer - Specialist; Technical Services; > BAX Global Inc. Irvine-California > Tel: 714-442-7591 Fax: 714-442-2840 > > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > From tbrannon at valueclick.com Wed Jun 8 15:16:02 2005 From: tbrannon at valueclick.com (Terrence Brannon) Date: Wed, 08 Jun 2005 15:16:02 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: References: Message-ID: <1118268962.9621.25.camel@tbrannon.dv.valueclick.com> On Wed, 2005-06-08 at 12:25 -0700, Ranga Nathan wrote: > I have a need to run a script when a file is received into a directory via > FTP. one question: does FTP show the file when the write is complete or while it is writing? There could be problems if you start processing a file which is not completely written. In former jobs, I trailed the intended upload with a small file signalling that the intended file was complete. Alternatively, I would rename the uploaded file to the file that the monitor process was looking for once it was completely uploaded. From pete at peterbenjamin.com Wed Jun 8 18:19:48 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 08 Jun 2005 18:19:48 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: References: Message-ID: <6.1.2.0.2.20050608181503.037c59b0@peterbenjamin.com> I'd tend to replace the existing FTP daemon with a perl based one, and just have the new perl FTP daemon receive the file, write it to disk, move it, and then spawn the software needed to process the file contents. That being so much work, I would stay with cron. One other alternative is to have the sending system, after FTP exits, to have the script there invoke ssh to run a command on the remote system to process the file. I've been told by gurus I respect that this is the best possible method. Along with a cron job on the receiving system to look for files that were not processed, due to the ssh failing, and it then doing "something", like emailing about this failure, and perhaps processing the file, even though it is late. Alternatively, use a database replication method instead of FTP, and use the database triggers. A lot of work though. From fred.kleindenst at citigroup.com Thu Jun 9 10:10:02 2005 From: fred.kleindenst at citigroup.com (Kleindenst, Fred) Date: Thu, 9 Jun 2005 13:10:02 -0400 Subject: [LA.pm] Monitoring a directory using Event.pm Message-ID: <1E6014B28FEE6F43A5F49C6628B7B85E039F5263@EXNJMB11.nam.nsroot.net> This problems seems like a common theme. I worked on such a system before. One element of the system that I found clever was that the directory watching deamon would notice new files, but it would wait until the size or checksum of the file remained constant. A CPAN search reveals: http://search.cpan.org/~trockij/mon-0.99.2/mon.d/file_change.monitor which would be the proverbial 90% of the code you need. Cheers --Fred > -----Original Message----- > From: losangeles-pm-bounces at pm.org > [mailto:losangeles-pm-bounces at pm.org]On Behalf Of Peter Benjamin > Sent: Wednesday, June 08, 2005 6:20 PM > To: Ranga Nathan; losangeles-pm at mail.pm.org > Subject: Re: [LA.pm] Monitoring a directory using Event.pm > > > > I'd tend to replace the existing FTP daemon with a perl based one, > and just have the new perl FTP daemon receive the file, write it > to disk, move it, and then spawn the software needed to process > the file contents. > > That being so much work, I would stay with cron. > > One other alternative is to have the sending system, after > FTP exits, to have the script there invoke ssh to run a > command on the remote system to process the file. > I've been told by gurus I respect that this is the > best possible method. > > Along with a cron job on the receiving system to look for > files that were not processed, due to the ssh failing, > and it then doing "something", like emailing about this > failure, and perhaps processing the file, even though it > is late. > > Alternatively, use a database replication method instead of > FTP, and use the database triggers. A lot of work though. > > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > From tbrannon at valueclick.com Thu Jun 9 10:15:47 2005 From: tbrannon at valueclick.com (Terrence Brannon) Date: Thu, 09 Jun 2005 10:15:47 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: <6.1.2.0.2.20050608181503.037c59b0@peterbenjamin.com> References: <6.1.2.0.2.20050608181503.037c59b0@peterbenjamin.com> Message-ID: <1118337347.9621.40.camel@tbrannon.dv.valueclick.com> On Wed, 2005-06-08 at 18:19 -0700, Peter Benjamin wrote: > I'd tend to replace the existing FTP daemon with a perl based one, What a slick idea! Net::FTPServer has mega-hooks just for this purpose. You can _competely_ configure FTP pre and post - processing. I had great fun with it on a large project once. The developer is very responsive and very astute. From tbrannon at valueclick.com Thu Jun 9 10:17:16 2005 From: tbrannon at valueclick.com (Terrence Brannon) Date: Thu, 09 Jun 2005 10:17:16 -0700 Subject: [LA.pm] Monitoring a directory using Event.pm In-Reply-To: <1E6014B28FEE6F43A5F49C6628B7B85E039F5263@EXNJMB11.nam.nsroot.net> References: <1E6014B28FEE6F43A5F49C6628B7B85E039F5263@EXNJMB11.nam.nsroot.net> Message-ID: <1118337436.9621.43.camel@tbrannon.dv.valueclick.com> I still think trailing the uploaded file with a flagged file is better unless you are using hooks into the file-reception scheme. This is because a network lag or client shutdown would stop differences in file size on the server, but not because the file was completely transferred. > This problems seems like a common theme. > > I worked on such a system before. One element of the system that I found clever was that the directory watching deamon would notice new files, but it would wait until the size or checksum of the file remained constant. A CPAN search reveals: > > http://search.cpan.org/~trockij/mon-0.99.2/mon.d/file_change.monitor > > which would be the proverbial 90% of the code you need. > > Cheers > > --Fred > > > > -----Original Message----- > > From: losangeles-pm-bounces at pm.org > > [mailto:losangeles-pm-bounces at pm.org]On Behalf Of Peter Benjamin > > Sent: Wednesday, June 08, 2005 6:20 PM > > To: Ranga Nathan; losangeles-pm at mail.pm.org > > Subject: Re: [LA.pm] Monitoring a directory using Event.pm > > > > > > > > I'd tend to replace the existing FTP daemon with a perl based one, > > and just have the new perl FTP daemon receive the file, write it > > to disk, move it, and then spawn the software needed to process > > the file contents. > > > > That being so much work, I would stay with cron. > > > > One other alternative is to have the sending system, after > > FTP exits, to have the script there invoke ssh to run a > > command on the remote system to process the file. > > I've been told by gurus I respect that this is the > > best possible method. > > > > Along with a cron job on the receiving system to look for > > files that were not processed, due to the ssh failing, > > and it then doing "something", like emailing about this > > failure, and perhaps processing the file, even though it > > is late. > > > > Alternatively, use a database replication method instead of > > FTP, and use the database triggers. A lot of work though. > > > > _______________________________________________ > > Losangeles-pm mailing list > > Losangeles-pm at pm.org > > http://mail.pm.org/mailman/listinfo/losangeles-pm > > > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm From fred.kleindenst at citigroup.com Thu Jun 9 10:28:46 2005 From: fred.kleindenst at citigroup.com (Kleindenst, Fred) Date: Thu, 9 Jun 2005 13:28:46 -0400 Subject: [LA.pm] Monitoring a directory using Event.pm Message-ID: <1E6014B28FEE6F43A5F49C6628B7B85E039F5264@EXNJMB11.nam.nsroot.net> Good point. If the trailing file is a checksum of the orginal file, then it adds another useful bit(s) of information. The Net::FTPServer module looks like a robust, lazy way to go. Cheers --Fred > -----Original Message----- > From: Terrence Brannon [mailto:tbrannon at valueclick.com] > > I still think trailing the uploaded file with a flagged file is better > unless you are using hooks into the file-reception scheme. > > This is because a network lag or client shutdown would stop > differences > in file size on the server, but not because the file was completely > transferred. > > > This problems seems like a common theme. > > > > I worked on such a system before. One element of the > system that I found clever was that the directory watching > deamon would notice new files, but it would wait until the > size or checksum of the file remained constant. A CPAN > search reveals: > > > > http://search.cpan.org/~trockij/mon-0.99.2/mon.d/file_change.monitor > > > > which would be the proverbial 90% of the code you need. > > > > Cheers > > > > --Fred > > > > > > > -----Original Message----- > > > From: losangeles-pm-bounces at pm.org > > > [mailto:losangeles-pm-bounces at pm.org]On Behalf Of Peter Benjamin > > > Sent: Wednesday, June 08, 2005 6:20 PM > > > To: Ranga Nathan; losangeles-pm at mail.pm.org > > > Subject: Re: [LA.pm] Monitoring a directory using Event.pm > > > > > > > > > > > > I'd tend to replace the existing FTP daemon with a perl based one, > > > and just have the new perl FTP daemon receive the file, write it > > > to disk, move it, and then spawn the software needed to process > > > the file contents. > > > > > > That being so much work, I would stay with cron. > > > > > > One other alternative is to have the sending system, after > > > FTP exits, to have the script there invoke ssh to run a > > > command on the remote system to process the file. > > > I've been told by gurus I respect that this is the > > > best possible method. > > > > > > Along with a cron job on the receiving system to look for > > > files that were not processed, due to the ssh failing, > > > and it then doing "something", like emailing about this > > > failure, and perhaps processing the file, even though it > > > is late. > > > > > > Alternatively, use a database replication method instead of > > > FTP, and use the database triggers. A lot of work though. > > > > > > _______________________________________________ > > > Losangeles-pm mailing list > > > Losangeles-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/losangeles-pm > > > > > _______________________________________________ > > Losangeles-pm mailing list > > Losangeles-pm at pm.org > > http://mail.pm.org/mailman/listinfo/losangeles-pm > From glim at mycybernet.net Thu Jun 16 21:47:00 2005 From: glim at mycybernet.net (Gerard Lim) Date: Fri, 17 Jun 2005 00:47 -0400 Subject: [LA.pm] Last-minute reminder -- YAPC::NA 2005 Message-ID: Here's a last reminder about Yet Another Perl Conference, North America (YAPC::NA 2005) http://yapc.org/America In case anyone out there has been sitting on the fence or has been meaning to register but has put it on the backburner until now, here is a final information package. Dates: Mon - Wed June 27 - 29, 2005 (11 days from now!) Location: 89 Chestnut Street, University of Toronto, Toronto, Ontario, Canada Accommodations ============== Due to recent renegotiations with the conference facility and hotel, 89 Chestnut, there are still a few rooms left. For details on accommodations go to: http://www.yapc.org/America/accommodations-2005.shtml For quick and easy booking: 89 Chestnut Phone: +1-416-977-0707 Conference booking code: perl0626 The base rate is approx. CAD$80/night, which is *great* for downtown Toronto. Add in taxes and in-room high speed internet and it's up to about CAD$95/night. Book yourself to check-in on Sunday the 26th and check-out on the morning of Wednesday the 29th. Conference Registration ======================= Registration is easy and cheap - only USD$85 - see http://yapc.org/America/register-2005.shtml for details or register directly online at http://donate.perlfoundation.org/index.pl?node=registrant%20info&conference_id=423 The schedule is awesome - http://yapc.org/America/schedule-2005/day1.html >From here, click on the "Day 2" and "Day 3" spots near the top to go from page to page. Click on a talk name to get details regarding the talk. Speakers include Larry Wall, Allison Randal, Autrijus Tang, Brian Ingerson, Andy Lester, chromatic, brian d foy, Chip Salzenberg & Dan Sugalski... and many more! [ This message was sent by Gerard Lim on behalf of the YAPC::NA 2005 Conference organizing committee of the Toronto Perl Mongers. Thanks for your patience and support. ] From david at cloudgraphics.com Thu Jun 23 09:05:51 2005 From: david at cloudgraphics.com (David Heayn) Date: Thu, 23 Jun 2005 12:05:51 -0400 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <42A671AD.5070207@modperlcookbook.org> References: <42A671AD.5070207@modperlcookbook.org> Message-ID: I have an ultra simple perl script that requests the current date/time from a shared server (not mine) then spits out the html dressing. My problem is the server is set to Pacific time and I need Eastern time. Anyone have any suggestions/alternative server time mechanisms. I'd rather not go in and program a complete time zone remapping function. Thanks. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From dpisoni at shopzilla.com Thu Jun 23 09:21:07 2005 From: dpisoni at shopzilla.com (David Pisoni) Date: Thu, 23 Jun 2005 09:21:07 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> Message-ID: <9ad4890f7a96b61de5884af462ceda29@shopzilla.com> On Jun 23, 2005, at 9.05, David Heayn wrote: > I have an ultra simple perl script that requests the current > date/time from a shared server (not mine) then spits out the html > dressing. > > My problem is the server is set to Pacific time and I need Eastern > time. > > Anyone have any suggestions/alternative server time mechanisms. I'd > rather not go in and program a complete time zone remapping function. > > Thanks. > > David Heayn * http://www.cloudgraphics.com * 213/925.3283 > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm David, I just ran into this issue recently. I came up with a solution, though it isn't entirely portable, so YMMV. This works on my Linux system and my MacOS X system: print scalar localtime; # outputs local Pacific time { # block to insulate time zone change local $ENV{TZ} = 'America/New York'; # Or I could say 'EST5EDT' print scalar localtime; # outputs local Eastern time } The valid values for the TZ environment variable are the files located in '/usr/share/zoneinfo' (on both my systems.) There are files at the top level (e.g., 'EST5EDT') and a directory hierarchy (e.g., 'America/New_York'). Spaces in the environment variable get mapped to underscores on the filesystem. On my systems, the default state of the environment variable is undefined: other factors are determining the home locale. The environment variable seems to serve as an "override", at least from the perspective of the perl runtime. In my exploration of the topic I ran across POSIX::tzset, which seemed entirely unnecessary on my system. Perhaps some systems would require this call. Essentially all it does is set the internal time zone to the current value of $ENV{TZ}. Enjoy, David Pisoni dpisoni at shopzilla.com Director, Web Engineering Shopzilla, Inc. "One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man." - Elbert Hubbard, author, editor, printer (1856-1915) From Peter at PSDT.com Thu Jun 23 09:50:07 2005 From: Peter at PSDT.com (Peter Scott) Date: Thu, 23 Jun 2005 09:50:07 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> Message-ID: <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> At 09:05 AM 6/23/2005, David Heayn wrote: >I have an ultra simple perl script that requests the current >date/time from a shared server (not mine) then spits out the html >dressing. > >My problem is the server is set to Pacific time and I need Eastern time. > >Anyone have any suggestions/alternative server time mechanisms. I'd >rather not go in and program a complete time zone remapping function. Um, since eastern time is always 3 hours ahead of pacific, you should just be able to do % date Thu Jun 23 09:47:35 PDT 2005 % perl -MDate::Parse -le 'print scalar localtime(str2time("Thu Jun 23 09:38:22 PDT 2005")+3600*3)' Thu Jun 23 12:38:22 2005 I can't tell from your post whether your program is running on the same machine that's giving you the date you want, what format you're getting it in, or what format you want it in. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ http://www.perlmedic.com/ From geoff at modperlcookbook.org Thu Jun 23 10:50:54 2005 From: geoff at modperlcookbook.org (Geoffrey Young) Date: Thu, 23 Jun 2005 13:50:54 -0400 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> Message-ID: <42BAF67E.9020504@modperlcookbook.org> Peter Scott wrote: > At 09:05 AM 6/23/2005, David Heayn wrote: > >>I have an ultra simple perl script that requests the current >>date/time from a shared server (not mine) then spits out the html >>dressing. >> >>My problem is the server is set to Pacific time and I need Eastern time. >> >>Anyone have any suggestions/alternative server time mechanisms. I'd >>rather not go in and program a complete time zone remapping function. > > > Um, since eastern time is always 3 hours ahead of pacific that's not entirely true - daylight savings starts/ends at 2am local time on the days that it switches, so 1:59am EST magically becomes 3am EDT while it went from 10:59pm to 11:00pm PST, thus leaving a 4 hour difference for the next 3 hours. madness :) --Geoff From Peter at PSDT.com Thu Jun 23 10:56:58 2005 From: Peter at PSDT.com (Peter Scott) Date: Thu, 23 Jun 2005 10:56:58 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <42BAF67E.9020504@modperlcookbook.org> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> Message-ID: <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> At 10:50 AM 6/23/2005, Geoffrey Young wrote: > > Um, since eastern time is always 3 hours ahead of pacific > >that's not entirely true - daylight savings starts/ends at 2am local time on >the days that it switches, so 1:59am EST magically becomes 3am EDT while it >went from 10:59pm to 11:00pm PST, thus leaving a 4 hour difference for the >next 3 hours. > >madness :) All the more reason to stay in bed then :-) -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ http://www.perlmedic.com/ From dpisoni at shopzilla.com Thu Jun 23 11:14:20 2005 From: dpisoni at shopzilla.com (David Pisoni) Date: Thu, 23 Jun 2005 11:14:20 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <42BAF67E.9020504@modperlcookbook.org> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> Message-ID: On Jun 23, 2005, at 10.50, Geoffrey Young wrote: > > > Peter Scott wrote: >> At 09:05 AM 6/23/2005, David Heayn wrote: >> >>> I have an ultra simple perl script that requests the current >>> date/time from a shared server (not mine) then spits out the html >>> dressing. >>> >>> My problem is the server is set to Pacific time and I need Eastern >>> time. >>> >>> Anyone have any suggestions/alternative server time mechanisms. I'd >>> rather not go in and program a complete time zone remapping function. >> >> >> Um, since eastern time is always 3 hours ahead of pacific > > that's not entirely true - daylight savings starts/ends at 2am local > time on > the days that it switches, so 1:59am EST magically becomes 3am EDT > while it > went from 10:59pm to 11:00pm PST, thus leaving a 4 hour difference for > the > next 3 hours. > > madness :) > > --Geoff Hence the reason for using the system-supplied zone info records. It manages DST issues. This scenario can be even more complex ? consider that all US locales (that use daylight savings) switch their clocks at 2.00 local time, but all European locales (again, that use DST) switch their clocks at the SAME time globally (1.00 UTC.) Simply adding or subtracting hours just won't cut it! Enjoy, David Pisoni dpisoni at shopzilla.com Director, Web Engineering Shopzilla, Inc. "Education is a progressive discovery of our own ignorance." -Will Durant, historian (1885-1981) From pete at peterbenjamin.com Thu Jun 23 11:31:40 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 23 Jun 2005 11:31:40 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> Message-ID: <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> I would not write any date manipulation code when CPAN provides a wide wealth of them, easily used. Consider CPAN modules for handling time zones and changing the local time to others by using supplied modules like "add" or "subtract." The output date format can be one of several dozens per yet another date module. The same for the input format. Simply amazing the range of date handling capability available via CPAN. So much so, it makes it hard to find the feature you want among the hundreds of date functions. Do be careful in selecting the date modules you use. There are duplicate functionality modules, and the most popular date modules are the only ones I would use, leaving the half grown ones never installed. I wish I could tell you wish they are off the top of my head, but I do not recall. Perhaps someone can name them? I think I only use 3 of them. There is little duplicate functionality between the three I have used. From ehammond at thinksome.com Thu Jun 23 14:00:49 2005 From: ehammond at thinksome.com (Eric Hammond) Date: Thu, 23 Jun 2005 14:00:49 -0700 Subject: [LA.pm] OT: changing the date timezone for perl use In-Reply-To: <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> Message-ID: <20050623210049.GA24476@level22.com> Peter Benjamin wrote: > I wish I could tell you wish they are off the top of > my head, but I do not recall. Perhaps someone can I tend to use Date::Manip, mainly because it can take a variety of different formats as input. It can be confusing to figure out how to use, though, as the interface is not intuitive (to me). -- Eric Hammond ehammond at thinksome.com From david at cloudgraphics.com Fri Jun 24 22:13:40 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 01:13:40 -0400 Subject: [LA.pm] how do I trim a $var down In-Reply-To: <20050623210049.GA24476@level22.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> Message-ID: I want to spit out summaries of a CSV file to HTML, where $content sometimes runs 3000+ characters long. However, I need a way to strip off the bulk of $content, but keep the first 100 characters/whitespaces. Ideas? David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Fri Jun 24 22:32:33 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 01:32:33 -0400 Subject: [LA.pm] how do I trim a $var down In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> Message-ID: At 10:16 PM -0700 6/24/05, Kevin Scaldeferri wrote: >On Jun 24, 2005, at 10:13 PM, David Heayn wrote: > >>I want to spit out summaries of a CSV file to HTML, where $content >>sometimes runs 3000+ characters long. However, I need a way to strip >>off the bulk of $content, but keep the first 100 >>characters/whitespaces. >> >>Ideas? >> > >substr? > >-kevin Thank you Kevin. I came up with this line out of the camel book... substr($content, 101) = ""; but I get an error: substr outside of string at cgi-bin/blog.cgi line 38. I'm missing something. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From md5 at embody.org Fri Jun 24 22:43:01 2005 From: md5 at embody.org (Mike Dillon) Date: Fri, 24 Jun 2005 22:43:01 -0700 Subject: [LA.pm] how do I trim a $var down In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> Message-ID: <20050625054301.GA29034@hygelac.int.embody.org> begin David Heayn quotation: > I came up with this line out of the camel book... > > substr($content, 101) = ""; > > > > but I get an error: > > substr outside of string at cgi-bin/blog.cgi line 38. > > > I'm missing something. You only should do it if the string is actually longer than 100: substr($content, 101) = "" if length $content > 100; -md From david at cloudgraphics.com Fri Jun 24 22:55:15 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 01:55:15 -0400 Subject: [LA.pm] how do I trim a $var down In-Reply-To: <20050625054301.GA29034@hygelac.int.embody.org> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: At 10:43 PM -0700 6/24/05, Mike Dillon wrote: > > >You only should do it if the string is actually longer than 100: > > substr($content, 101) = "" if length $content > 100; > >-md Thanks Mike. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 12:34:14 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 15:34:14 -0400 Subject: [LA.pm] alternating... In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: I'm trying to alternate between printing dark blue rows of an HTML table and just blue rows. However, I'm not getting the results I want. In fact, I even know why the below code doesn't work. If you have any suggestions on how to switch between two colors on table rows I would love to hear it. foreach my $line (@mem) { if ($color == 0) { print ""; $color = 1; } elsif($color == 1) { print ""; $color = 0; } print "$line\n\n"; } btw- This is the meat of what the script prints out: http:// # this loop went well http:// # another good one... http:// # problems here... double TR's http:// #lots of problems here... 7 TR tags before getting to what's important. I hope this is all clear. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From pete at peterbenjamin.com Sat Jun 25 13:00:21 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Sat, 25 Jun 2005 13:00:21 -0700 Subject: [LA.pm] alternating... In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> A case to try perl -d to see code execution order, as I can not see what is wrong via visual inspection and it worked for me with this initialization: my @mem = ( "1", "2", "3", "4", "5", "6", "7", ); I do suggest you avoid variable names that might conflict with reserved words, as "$line" might do in some languages, just on general principles. Same with mem, which is an unix command. Post your test data for @mem would be good. Starting $color as uninitialized is not wise, imo. Also, try perl -w and strict for more detailed error messages. Trick: avoid \" inside of double quoted strings by using just ' -p At 12:34 PM 6/25/2005, David Heayn wrote: >I'm trying to alternate between printing dark blue rows of an HTML >table and just blue rows. However, I'm not getting the results I >want. In fact, I even know why the below code doesn't work. If you >have any suggestions on how to switch between two colors on table >rows I would love to hear it. > > >foreach my $line (@mem) > { > if ($color == 0) > { > print ""; > $color = 1; > } > elsif($color == 1) > { > print ""; > $color = 0; > } > > print "$line\n\n"; > } > > > > > >btw- This is the meat of what the script prints out: > > > >http:// ># this loop went well >http:// ># another good one... >bgcolor="#93c0c0">http:// ># problems here... double TR's >bgcolor="#cae8ff">bgcolor="#cae8ff">bgcolor="#cae8ff">HREF="http://">http:// >#lots of problems here... 7 TR tags before getting to what's important. > > >I hope this is all clear. > > > >David Heayn * http://www.cloudgraphics.com * 213/925.3283 >_______________________________________________ >Losangeles-pm mailing list >Losangeles-pm at pm.org >http://mail.pm.org/mailman/listinfo/losangeles-pm From wdr1 at pobox.com Sat Jun 25 13:08:25 2005 From: wdr1 at pobox.com (William Reardon) Date: Sat, 25 Jun 2005 13:08:25 -0700 Subject: [LA.pm] alternating... In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: Your snippet by itself works, so you must be doing something wrong elsewhere in the script. Are you messing with $line anywhere? Make sure you have warnings on ("use warnings" at the top) and see what that says. Here's an easier way to do the same thing, using the modulo operator: my @mem = qw|foo bar baz bang bong bing ding dong dang|; my $n = 0; foreach my $line (@mem) { print '$line\n\n"; } HTH, -Bill At 3:34 PM -0400 6/25/05, David Heayn wrote: >I'm trying to alternate between printing dark blue rows of an HTML >table and just blue rows. However, I'm not getting the results I >want. In fact, I even know why the below code doesn't work. If you >have any suggestions on how to switch between two colors on table >rows I would love to hear it. > >foreach my $line (@mem) > { > if ($color == 0) > { > print ""; > $color = 1; > } > elsif($color == 1) > { > print ""; > $color = 0; > } > > print "$line\n\n"; > } > > > > > >btw- This is the meat of what the script prints out: > > > >http:// ># this loop went well >http:// ># another good one... >bgcolor="#93c0c0">http:// ># problems here... double TR's >bgcolor="#cae8ff">bgcolor="#cae8ff">bgcolor="#cae8ff">HREF="http://">http:// >#lots of problems here... 7 TR tags before getting to what's important. > > >I hope this is all clear. > > > >David Heayn * http://www.cloudgraphics.com * 213/925.3283 >_______________________________________________ >Losangeles-pm mailing list >Losangeles-pm at pm.org >http://mail.pm.org/mailman/listinfo/losangeles-pm From david at cloudgraphics.com Sat Jun 25 13:24:58 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 16:24:58 -0400 Subject: [LA.pm] alternating... In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: Thank you all for quick responses. In my script I am using strict, and -w. The script parses a log file for refer tags. I ran it through the debugger and this came out: -jailshell-2.05b$ perl -d refer.pl > results.html Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(refer.pl:4): my $fileLoc = "markhe.access_log-06.23.05"; Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at /usr/lib/perl5/site_perl/5.8.4/i686-linux/Term/ReadKey.pm line 362. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.4/Term/ReadLine/Perl.pm line 58. at /usr/lib/perl5/site_perl/5.8.4/Term/ReadLine/Perl.pm line 58 Term::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'GLOB(0x81e4548)', 'GLOB(0x81aa2e0)') called at /usr/lib/perl5/5.8.6/perl5db.pl line 6029 DB::setterm called at /usr/lib/perl5/5.8.6/perl5db.pl line 2203 DB::DB called at refer.pl line 4 Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. The variable at line 4 is something I can't change. The server names those and allows me read-only access. I'm thinking the the double "." have something to do with it. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 13:42:05 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 16:42:05 -0400 Subject: [LA.pm] alternating... In-Reply-To: <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: At 1:00 PM -0700 6/25/05, Peter Benjamin wrote: >I do suggest you avoid variable names that might conflict >with reserved words, as "$line" might do in some languages, >just on general principles. Same with mem, which is an unix >command. I renamed @mem and $line. I still have problems. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 14:20:26 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 17:20:26 -0400 Subject: [LA.pm] alternating...solved In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: My problem was I was only looking at where I thought the problem would be. It turns out I was actually using several nested lops together (and simplifying for this list) and I wasn't taking into account tests that threw away array elements and also accidently triggered tags ... David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 18:52:35 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 21:52:35 -0400 Subject: [LA.pm] CGI problem In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: I'm having a frustrating time coding up a CGI mechanism. Basically, below prints out an HTML form (that was generated in a web editor, not by hand), unless the Param() function is filled. The printing of a blank form works fine, however, when I send data back to the script I get an "Internal Server Error." I have Lincoln Stein's cgi.pm book but he doesn't go into detail about how to handle form: drop down menu options. What am I doing wrong? #!/usr/local/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); warningsToBrowser(1); use lib qw( ..); my $cgiLoc = "http://www.cloudgraphics.com/cgi-bin/refer.cgi"; if (param('action')) { print "\n"; print "\n"; my $year = param('year'); my $month = param('mo'); my $day = param('day'); print "$month/$day/$year
\n"; print "\n"; } else { print < [snip]
//

HTML_BLOCK } David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 19:06:08 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 22:06:08 -0400 Subject: [LA.pm] CGI problem -update In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: At 9:52 PM -0400 6/25/05, David Heayn wrote: >I'm having a frustrating time coding up a CGI mechanism. I just learned about the cgi interactive mode. Typing in the values manually through the shell gives me the expected results... just not live on the web. :-( David Heayn * http://www.cloudgraphics.com * 213/925.3283 From david at cloudgraphics.com Sat Jun 25 19:39:16 2005 From: david at cloudgraphics.com (David Heayn) Date: Sat, 25 Jun 2005 22:39:16 -0400 Subject: [LA.pm] CGI problem -solved In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: My problem was not including: print header; before the tags. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From andy at petdance.com Sat Jun 25 20:01:12 2005 From: andy at petdance.com (Andy Lester) Date: Sat, 25 Jun 2005 22:01:12 -0500 Subject: [LA.pm] alternating...solved In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.1.2.0.2.20050625125347.0389a0e0@peterbenjamin.com> Message-ID: <8316DECD-A53D-4077-A307-591BD360F0D8@petdance.com> On Jun 25, 2005, at 4:20 PM, David Heayn wrote: > My problem was I was only looking at where I thought the problem > would be. It turns out I was actually using several nested lops You could also look at a module that would take care of it for you, such as Tie::Cycle or List::Cycle. xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jeff at yoak.com Sat Jun 25 20:22:52 2005 From: jeff at yoak.com (Jeff Yoak) Date: Sat, 25 Jun 2005 20:22:52 -0700 Subject: [LA.pm] alternating... In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> Message-ID: <6.0.3.0.0.20050625202100.022fa5c0@mail.sexypanda.com> At 01:08 PM 6/25/2005, William Reardon wrote: >Here's an easier way to do the same thing, using the modulo operator: > >my @mem = qw|foo bar baz bang bong bing ding dong dang|; > >my $n = 0; >foreach my $line (@mem) { > print '$line\n\n"; >} And even easier without it: my @mem = qw|foo bar baz bang bong bing ding dong dang|; foreach my $line (@mem) { print '$line\n\n"; } Oh, wait. This isn't the fwp mailing list. Never mind. ;-) Cheers, Jeff From rspier at pobox.com Sat Jun 25 22:20:17 2005 From: rspier at pobox.com (Robert Spier) Date: Sat, 25 Jun 2005 22:20:17 -0700 Subject: [LA.pm] alternating... In-Reply-To: <6.0.3.0.0.20050625202100.022fa5c0@mail.sexypanda.com> References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.0.3.0.0.20050625202100.022fa5c0@mail.sexypanda.com> Message-ID: > print '$line\n\n"; > } > Oh, wait. This isn't the fwp mailing list. Never mind. ;-) Cute, although abuse of $| considered dangerous. Of course, the _right_ way to do this is with CSS3. http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#nth-child-pseudo From david at cloudgraphics.com Mon Jun 27 05:12:30 2005 From: david at cloudgraphics.com (David Heayn) Date: Mon, 27 Jun 2005 08:12:30 -0400 Subject: [LA.pm] user installed modules In-Reply-To: References: <42A671AD.5070207@modperlcookbook.org> <6.1.2.0.2.20050623094535.03407ba8@mail.webquarry.com> <42BAF67E.9020504@modperlcookbook.org> <6.1.2.0.2.20050623105635.036f3ec0@mail.webquarry.com> <6.1.2.0.2.20050623112643.055dd150@peterbenjamin.com> <20050623210049.GA24476@level22.com> <20050625054301.GA29034@hygelac.int.embody.org> <6.0.3.0.0.20050625202100.022fa5c0@mail.sexypanda.com> Message-ID: My admin guys are kind of slow to add perl modules to the server. Could you list a man page/web page that explains how I can install a couple into my home directory? Thanks. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From fred.kleindenst at citigroup.com Mon Jun 27 11:13:00 2005 From: fred.kleindenst at citigroup.com (Kleindenst, Fred) Date: Mon, 27 Jun 2005 14:13:00 -0400 Subject: [LA.pm] user installed modules Message-ID: <1E6014B28FEE6F43A5F49C6628B7B85E039F52A6@EXNJMB11.nam.nsroot.net> Here you go: http://perlmonks.org/index.pl?node=128077#permission > -----Original Message----- > From: losangeles-pm-bounces at pm.org > [mailto:losangeles-pm-bounces at pm.org]On Behalf Of David Heayn > Sent: Monday, June 27, 2005 5:13 AM > To: losangeles-pm at pm.org > Subject: [LA.pm] user installed modules > > > My admin guys are kind of slow to add perl modules to the server. > > Could you list a man page/web page that explains how I can install a > couple into my home directory? > > Thanks. > > > > David Heayn * http://www.cloudgraphics.com * 213/925.3283 > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm > From david at cloudgraphics.com Tue Jun 28 21:28:38 2005 From: david at cloudgraphics.com (David Heayn) Date: Wed, 29 Jun 2005 00:28:38 -0400 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <1E6014B28FEE6F43A5F49C6628B7B85E039F52A6@EXNJMB11.nam.nsroot.net> References: <1E6014B28FEE6F43A5F49C6628B7B85E039F52A6@EXNJMB11.nam.nsroot.net> Message-ID: I'm working with a script that needs to decompress log files before it can read them as text. I hope to use a system() command and I found this almost perfect snippet to place inside: find . -name '*.gz' -print | sed 's/^\(.*\)[.]gz$/gunzip < "&" > "\1"/' | s from http://www.gnu.org/software/gzip/manual/html_chapter/gzip_3.html#SEC6 This is great, however I really want to delete the all *.gz files once I'm done with them. Any suggestions? Or would you go an entirely different way? David Heayn * http://www.cloudgraphics.com * 213/925.3283 From ben_tilly at operamail.com Tue Jun 28 21:36:37 2005 From: ben_tilly at operamail.com (Benjamin J. Tilly ) Date: Wed, 29 Jun 2005 12:36:37 +0800 Subject: [LA.pm] calling gzip from within perl Message-ID: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> An embedded and charset-unspecified text was scrubbed... Name: not available Url: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050629/fe832159/attachment.pl From david at cloudgraphics.com Tue Jun 28 22:21:30 2005 From: david at cloudgraphics.com (David Heayn) Date: Wed, 29 Jun 2005 01:21:30 -0400 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> Message-ID: At 12:36 PM +0800 6/29/05, Benjamin J. Tilly wrote: >Why do you need to decompress them beforehand? > > open(LOG, "gunzip $file |") or die "Cannot gunzip '$file': $!"; > >Or you can avoid the implicit system command by using >Compress::Zlib. I tried the code above. It decompressed the files (and erased the original) but perl didn't properly display them. In fact, it displayed nothing but the html title and header. The changed code is below. if (param('action')) { print header; my $year = param('year'); my $month = param('mo'); my $day = param('day'); my $seekLog = "access_log-$month.$day.$year"; my $fileLoc = "$logDir$seekLog.gz"; open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; my @stuff = ; close(FILE); Do i need to install compress:zlib to get this to work correctly? thanks! (oh, and I love this list) David Heayn * http://www.cloudgraphics.com * 213/925.3283 From pete at peterbenjamin.com Wed Jun 29 00:21:20 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 29 Jun 2005 00:21:20 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> Message-ID: <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> At 10:21 PM 6/28/2005, David Heayn wrote: >At 12:36 PM +0800 6/29/05, Benjamin J. Tilly wrote: >>Why do you need to decompress them beforehand? >> >> open(LOG, "gunzip $file |") or die "Cannot gunzip '$file': $!"; >> >>Or you can avoid the implicit system command by using >>Compress::Zlib. > >I tried the code above. It decompressed the files (and erased the >original) but perl didn't properly display them. In fact, it >displayed nothing but the html title and header. > >The changed code is below. > >if (param('action')) > { > print header; > my $year = param('year'); > my $month = param('mo'); > my $day = param('day'); > my $seekLog = "access_log-$month.$day.$year"; > my $fileLoc = "$logDir$seekLog.gz"; > open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; > my @stuff = ; > close(FILE); > > >Do i need to install compress:zlib to get this to work correctly? Should not need to. The gunzip that is invoked is the same as system would do. Does your script use STDIN? If so, then this method of re-using STDIN (the pipe after the filename in the open) would cause problems. They share the same /dev/* file name that STDIN uses. As it appears to be a CGI script I suppose you will not be able to re-use STDIN using the | inside the open. BTW, as you know the $logDir why not use () to expand the file list? And capture output from gunzip for errors or success? chdir $logDir; foreach my $fileLoc ( access_log-*.gz ) { my $stdout = `gunzip $fileLoc`; if ( $stdout =~ /(error1mesg|error2mesg)/ { # handle error. } elsif ( $stdout =~ /successmesg/ ) { $fileLoc =~ /s\.gz//'; open(FILE, "<$fileLoc") or die "Cannot open '$fileLoc': $!"; my @stuff = ; close(FILE); ...more... unlink $fileLoc; } else { die "Cannot gunzip '$fileLoc':\n$stdout\n"; } } Got to love perl shortcuts! From rspier at pobox.com Wed Jun 29 08:06:23 2005 From: rspier at pobox.com (Robert Spier) Date: Wed, 29 Jun 2005 08:06:23 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> Message-ID: > >> open(LOG, "gunzip $file |") or die "Cannot gunzip '$file': $!"; > > open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; You really want: gunzip -c From jleader at alumni.caltech.edu Wed Jun 29 12:02:29 2005 From: jleader at alumni.caltech.edu (Jeremy Leader) Date: Wed, 29 Jun 2005 12:02:29 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> Message-ID: <42C2F045.5000107@alumni.caltech.edu> Peter Benjamin wrote: > At 10:21 PM 6/28/2005, David Heayn wrote: >> open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; >> my @stuff = ; >> close(FILE); > > Does your script use STDIN? If so, then > this method of re-using STDIN (the pipe after the filename in > the open) would cause problems. They share the same /dev/* > file name that STDIN uses. As it appears to be a CGI script > I suppose you will not be able to re-use STDIN using the | > inside the open. But the snippet of code above doesn't use STDIN. The idiom open(FILE, "commandline |")... runs commandline and pipes its STDOUT to the handle FILE; it doesn't affect the current process's STDIN handle at all. Now if he'd written: close STDIN; open(STDIN, "commandline |")... then your point about re-using STDIN would be a valid concern. -- Jeremy Leader jleader at alumni.caltech.edu leaderj at yahoo-inc.com (work) From e at ericrichardson.com Wed Jun 29 12:39:18 2005 From: e at ericrichardson.com (eric richardson) Date: Wed, 29 Jun 2005 12:39:18 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <42C2F045.5000107@alumni.caltech.edu> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> Message-ID: <20050629193918.GD11741@gonzo> * Jeremy Leader (jleader at alumni.caltech.edu) wrote: > Peter Benjamin wrote: > > At 10:21 PM 6/28/2005, David Heayn wrote: > >> open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; > >> my @stuff = ; > >> close(FILE); Jumping late into the discussion and replying to the wrong message... That gzip call should be something like "gzip -dc $fileLoc |". The -c tells gzip to pipe to STDOUT, and I think that way it also doesn't delete the .gz file. e; -- eric richardson -- http://ericrichardson.com -- http://blogdowntown.com From pete at peterbenjamin.com Wed Jun 29 12:47:53 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 29 Jun 2005 12:47:53 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <42C2F045.5000107@alumni.caltech.edu> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> Message-ID: <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> At 12:02 PM 6/29/2005, Jeremy Leader wrote: >Peter Benjamin wrote: >> At 10:21 PM 6/28/2005, David Heayn wrote: >>> open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; >>> my @stuff = ; >>> close(FILE); > >> >> Does your script use STDIN? If so, then >> this method of re-using STDIN (the pipe after the filename in >> the open) would cause problems. They share the same /dev/* >> file name that STDIN uses. As it appears to be a CGI script >> I suppose you will not be able to re-use STDIN using the | >> inside the open. > >But the snippet of code above doesn't use STDIN. You're right, it uses STDOUT. I should not reply past midnight. CGI scripts also use STDOUT to send data back to the web server, so the point of reuse still applies, only now to STDOUT. Thanks for the correction Jeremy. From jleader at alumni.caltech.edu Wed Jun 29 13:31:47 2005 From: jleader at alumni.caltech.edu (Jeremy Leader) Date: Wed, 29 Jun 2005 13:31:47 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> Message-ID: <42C30533.6090408@alumni.caltech.edu> Peter Benjamin wrote: > At 12:02 PM 6/29/2005, Jeremy Leader wrote: >>Peter Benjamin wrote: >>>At 10:21 PM 6/28/2005, David Heayn wrote: >>>> open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; >>>> my @stuff = ; >>>> close(FILE); >> >>>Does your script use STDIN? If so, then >>>this method of re-using STDIN (the pipe after the filename in >>>the open) would cause problems. They share the same /dev/* >>>file name that STDIN uses. As it appears to be a CGI script >>>I suppose you will not be able to re-use STDIN using the | >>>inside the open. >> >>But the snippet of code above doesn't use STDIN. > > You're right, it uses STDOUT. I should not reply past midnight. > CGI scripts also use STDOUT to send data back to the web server, > so the point of reuse still applies, only now to STDOUT. > > Thanks for the correction Jeremy. But it's gzip's STDOUT which is piped to FILE, it doesn't affect the script's STDOUT, which is what CGI pipes back to the client. So I believe that it's okay to use this idiom (assuming you use the -c option to gzip, as Eric pointed out), even in a CGI script. -- Jeremy Leader jleader at alumni.caltech.edu leaderj at yahoo-inc.com (work) From pete at peterbenjamin.com Wed Jun 29 13:52:04 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 29 Jun 2005 13:52:04 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <42C30533.6090408@alumni.caltech.edu> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> <42C30533.6090408@alumni.caltech.edu> Message-ID: <6.1.2.0.2.20050629134039.0382f528@peterbenjamin.com> An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050629/f02df4b0/attachment.html From jleader at alumni.caltech.edu Wed Jun 29 14:13:26 2005 From: jleader at alumni.caltech.edu (Jeremy Leader) Date: Wed, 29 Jun 2005 14:13:26 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <6.1.2.0.2.20050629134039.0382f528@peterbenjamin.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> <42C30533.6090408@alumni.caltech.edu> <6.1.2.0.2.20050629134039.0382f528@peterbenjamin.com> Message-ID: <42C30EF6.3090102@alumni.caltech.edu> Peter Benjamin wrote: > At 01:31 PM 6/29/2005, Jeremy Leader wrote: >> But it's gzip's STDOUT which is piped to FILE, it doesn't >> affect the script's STDOUT, which is what CGI pipes back >> to the client. > > The CGI script runs as a single process id, and only has > one STDOUT identifier in the /dev directory. > > I read about this in an ORA perl book. > Mainly as 10 years ago I tried and tried and tried, > and never got it to work, and wondered why, so I > went looking. > > I could not quickly google an online reference. This came close: > > http://www.cs.usask.ca/resources/documentation/perl/perlfaq8.html > > *STDIN, STDOUT and STDERR are shared > *Both the main process and the backgrounded one (the ``child'' process) > share the same STDIN, STDOUT and STDERR filehandles. If both try to > access them at once, strange things can happen. You may want to close or > reopen these for the child. ...snip... > > -- > > But for CGI once you reopen the STDOUT, the parent can no longer pass > back data to the web server to give a web page to the surfer. Note that with '|', it's forking and execing the child, so it's running as a different process id from the parent. The faq entry you reference is talking about system() or fork(). The whole point of the '|' at the end of the string passed to open() is to tell it to do the appropriate opening, closing, and dup'ing of filehandles in the parent and child so that the child's STDOUT is piped to the opened handle (FILE) in the parent, and the parent's STDOUT is left untouched. Take a look at "perldoc -f open" (or http://www.cs.usask.ca/resources/documentation/perl/perlfunc.html#perlfunc_open_1) for a brief discussion of the use of '|', as well as an example of how to do the same thing yourself (saving STDOUT, opening a new file as STDOUT, and then reverting back to the original STDOUT), using >& to dup filehandles. Now if you just used fork() to run the child yourself, your concerns about STDOUT and CGI would be absolutely correct; in that case, you're not doing any redirection, and the parent and child share the same STDOUT, even though they're different processes. -- Jeremy Leader jleader at alumni.caltech.edu leaderj at yahoo-inc.com (work) From david at cloudgraphics.com Wed Jun 29 14:42:26 2005 From: david at cloudgraphics.com (David Heayn) Date: Wed, 29 Jun 2005 17:42:26 -0400 Subject: [LA.pm] calling gzip from within perl In-Reply-To: References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> Message-ID: At 8:06 AM -0700 6/29/05, Robert Spier wrote: > > >> open(LOG, "gunzip $file |") or die "Cannot gunzip '$file': $!"; > > > open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip >'$fileLoc': $!"; > >You really want: gunzip -c > Yep. this line more or less does the trick. It decompresses gz files to memory. open(FILE, "gunzip -c $fileLoc |") or die "Cannot gunzip '$fileLoc': $!"; However, when I took it over to another server the script didn't want to fully run. It printed a header and HTML title info, but the "data table" was empty. This secondary server I'm futzing with doesn't allow shell access or ssh'ing into any directories. Could this be the reason it doesn't work? I know that some of the compressed files are corrupt. Does the die "Can't gunzip $fileLoc... line test to see if there is a failed decompression attempt? David Heayn * http://www.cloudgraphics.com * 213/925.3283 From ben_tilly at operamail.com Wed Jun 29 19:46:23 2005 From: ben_tilly at operamail.com (Benjamin J. Tilly ) Date: Thu, 30 Jun 2005 10:46:23 +0800 Subject: [LA.pm] calling gzip from within perl Message-ID: <20050630024623.67F133AA515@ws5-8.us4.outblaze.com> An embedded and charset-unspecified text was scrubbed... Name: not available Url: http://mail.pm.org/pipermail/losangeles-pm/attachments/20050630/4ecee3ba/attachment.pl From pete at peterbenjamin.com Wed Jun 29 20:36:52 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 29 Jun 2005 20:36:52 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> Message-ID: <6.1.2.0.2.20050629203016.036df278@peterbenjamin.com> At 02:42 PM 6/29/2005, David Heayn wrote: >However, when I took it over to another server the script didn't want >to fully run. It printed a header and HTML title info, but the "data >table" was empty. This secondary server I'm futzing with doesn't >allow shell access or ssh'ing into any directories. Could this be the >reason it doesn't work? No. But the pathname to the gunzip might be wrong. That is $PATH does not include it. Ask the webhost what the full pathname is to gunzip and use that instead. $pathGunzip = "/usr/bin/local/gunzip"; ... open ( FH, "$pathGunzip -c |" )... >I know that some of the compressed files are >corrupt. Does the >die "Can't gunzip $fileLoc... >line test to see if there is a failed decompression attempt? No, but one of my posts shows you how to test STDERR via back tics to 'see' the messages. The STDERR within an open() can not be captured. Back tics I have found are best for this. Alternatively, the return code of gunzip is either 1 or 0, indicating good or fail (not sure which is which). See the man pages for more info. I have come to dislike using open pipes for anything but sending email via sendmail, which I find works fine all the time. Other times I have used an open pipe, I found troubleshooting the command required writing a special CGI to view the problem with backtics, or I wrote a CGI that gave me the equivalent of shell access, when ssh was not available. Thus, now I always use backtics and capture the output, so the CGI can echo it out, if even in html comments so it is not visible. Easy debugging that way. Just view source. From pete at peterbenjamin.com Wed Jun 29 20:39:22 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Wed, 29 Jun 2005 20:39:22 -0700 Subject: [LA.pm] calling gzip from within perl In-Reply-To: <42C30EF6.3090102@alumni.caltech.edu> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <42C2F045.5000107@alumni.caltech.edu> <6.1.2.0.2.20050629124618.03626220@peterbenjamin.com> <42C30533.6090408@alumni.caltech.edu> <6.1.2.0.2.20050629134039.0382f528@peterbenjamin.com> <42C30EF6.3090102@alumni.caltech.edu> Message-ID: <6.1.2.0.2.20050629203753.055d8cf0@peterbenjamin.com> At 02:13 PM 6/29/2005, Jeremy Leader wrote: >Note that with '|', it's forking and execing the child, so it's >running as a different process id from the parent. The faq entry >you reference is talking about system() or fork(). My recollection may be hazy. Or limited to certain OSes that do not work as well as unix. Likely it is mixed with using both STDIN and STDOUT within the same open, which does not work. Thanks Jeremy for your persistant correctness. From pete at peterbenjamin.com Thu Jun 30 13:56:40 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 30 Jun 2005 13:56:40 -0700 Subject: [LA.pm] CGI shell access - was: calling gzip from within perl In-Reply-To: References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <6.1.2.0.2.20050629203016.036df278@peterbenjamin.com> Message-ID: <6.1.2.0.2.20050630134259.03871c90@peterbenjamin.com> At 01:00 PM 6/30/2005 wrote: >Would you still have the source code to your faux shell cgi access, that you would be willing to share? I find this topic interesting and I'd like to know more about it. I write it new each time. It's about a dozen lines long. You can download freeware from many cgi libraries. It is dangerous code, and should always be password protected. Most ISPs will cancel your account if you use this. Check your TOS with them. Off the top of my head (not debugged nor tested): my $com = param(com); $| = 1; print "Content-type: text/html\n\n"; my @lines = `$com`; print "Return code=" . $!; # I think I recalled this right. foreach my $l ( @lines) { print $l . "
\n"; } print "
"; exit; The ones you can download have other features, like time expiring passwords, which is very good. Using it with SSL is a good idea, I think. Do notice that the command rm -rf / will work just fine, if the CGI is running with root access, or not. It will delete all files it can with the userid the CGI is running as. I like to add if ( $com =~ /rm/ ) { die"" } You should not run interactive commands like fdisk. Sometimes you will need to specify the full pathname to the executable. CGI jail is good to limit actions to just the cgi folder. Built in shell commands can be accessed via csh -e set or similar. Not that the profile or rc file will not be executed. From david at cloudgraphics.com Thu Jun 30 22:08:01 2005 From: david at cloudgraphics.com (David Heayn) Date: Fri, 1 Jul 2005 01:08:01 -0400 Subject: [LA.pm] global regex matches In-Reply-To: <6.1.2.0.2.20050630134259.03871c90@peterbenjamin.com> References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <6.1.2.0.2.20050629203016.036df278@peterbenjamin.com> <6.1.2.0.2.20050630134259.03871c90@peterbenjamin.com> Message-ID: I'm having a little bit of trouble with trying to find and custom-replace all the URL references within an array. I have this: foreach (@recordsRaw) { my $thingie = $_; if ($thingie =~ /(.*?)<\/a>/ig) { my $tempURL; $tempURL = $1; open(STUFF, "+>>$linkDat"); $rand = int(rand $maxN); my $rand2 = int(rand $maxN); my $encryptName = "$rand.$rand2"; print STUFF "$encryptName|$tempURL\n"; close(STUFF); $thingie =~ s/$tempURL/$redirLoc\?$encryptName/; push(@CleanArray, $thingie); } but it only acts upon the first URL it finds. BTW- I'm trying to track outbound links replacing "http://www.cnn.com" with "http://...redir?7584.2893" P.S. - For once, I don't think $thingie clashes with any other variables. David Heayn * http://www.cloudgraphics.com * 213/925.3283 From pete at peterbenjamin.com Thu Jun 30 22:56:07 2005 From: pete at peterbenjamin.com (Peter Benjamin) Date: Thu, 30 Jun 2005 22:56:07 -0700 Subject: [LA.pm] global regex matches In-Reply-To: References: <20050629043637.8A7DA3AA515@ws5-8.us4.outblaze.com> <6.1.2.0.2.20050629001140.090e9b38@peterbenjamin.com> <6.1.2.0.2.20050629203016.036df278@peterbenjamin.com> <6.1.2.0.2.20050630134259.03871c90@peterbenjamin.com> Message-ID: <6.1.2.0.2.20050630225421.0379aa30@peterbenjamin.com> At 10:08 PM 6/30/2005, David Heayn wrote: > $thingie =~ s/$tempURL/$redirLoc\?$encryptName/; add a g at the end? And the g in the if statement is not going to do what you expect. So, the g in the statement above will make all the URLs the same as $encryptName.