From Darren.Young at chicagobooth.edu Thu Dec 2 12:16:56 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Thu, 2 Dec 2010 20:16:56 +0000 Subject: [Chicago-talk] mkdir() question Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> I need some ideas on a problem I'm having doing mkdir and chown in Perl. The Perl script I have is running as a CGI under Apache 2.2.3 (RHEL). This script is the receiving end of a web service using SOAP::Lite (client is C# .NET). This script needs to do a mkdir for a user home directory and change permissions on it to that of the user (and their primary GID). Problem is Apache is running as the user "apache" (as it should) and therefore the script has no permissions do to a mkdir on /export/home. I haven't even gotten to the chown part, which if memory serves me correctly, won't work unless the script is being run as root. Can't change ownership of a directory to something other than yourself if you're not root right? I've considered the options of setuid-perl (argh), running the web server as something else (ugh) suexec under Apache or even setting the permissions on /export/home to that of apache. Though the latter won't solve the chown problem. Anyone have any other thoughts before I hang myself with setuid root? Darren Young Here's the worker code: ############################################################################### # NAME : _make_homedir # DESCRIPTION : Create a user home directory # ARGUMENTS : string(username), string(uid), string(type) # RETURN : 0 or 1 # NOTES : ############################################################################### sub _make_homedir { my ( $uname, $uid, $actype ) = @_; my $name = "_make_homedir"; logging::logmsg(STDERR, "$name: entering _make_homedirs()"); my $homedir = $config::GCH_HOMEDIR{$actype} . "/$uname"; my @skelfiles = ( '.cshrc', '.login', '.profile' ); my $skelbase = "$FindBin::Bin/skel"; my $gid = $config::GCH_GID{$actype}; my $retval = 1; ### Log the info logging::logmsg(STDERR, "$name: homedir => $homedir"); logging::logmsg(STDERR, "$name: skelbase => $skelbase"); logging::logmsg(STDERR, "$name: gid => $gid"); ############################################################################## ### Create the home directory ############################################################################## logging::logmsg(STDERR, "$name: Attempting to create directory: $homedir"); if ( !-d $homedir ) { if ( mkdir( "$homedir", 0720 ) ) { logging::logmsg(STDERR, "$name: Created home directory: $homedir"); } else { my $err = "FAILED to create home directory $homedir: $!"; logging::logmsg(STDERR, "$name: $err"); die($err); } } else { my $err = "FAILED to create directory $homedir: $homedir already exists"; logging::logmsg(STDERR, "$name: $err"); die("$err"); } ############################################################################## ### Change the ownership on the home directory ############################################################################## logging::logmsg(STDERR, "$name: Attempting to change ownership on: $homedir"); my $cnt = 0; $cnt = chown $uid, $gid, $homedir; if ( $cnt != 1 ) { my $err = "FAILED - home directory $homedir ownership not changed: $!"; logging::logmsg(STDERR, "$name: $err"); die($err); } else { logging::logmsg(STDERR, "$name: $homedir ownership changed to $uid:$gid"); $retval = 1; } ############################################################################## ### Copy all the skel files and set their perms ############################################################################## foreach my $file (@skelfiles) { if ( !copy( "$skeldir/$file", "$homedir" ) ) { logging::logmsg(STDERR, "$name: FAILED to copy $skeldir/$file to $homedir"); $retval = 0; } else { logging::logmsg(STDERR, "$name: Copied $skeldir/$file to $homedir"); $retval = 1; } $cnt = chown $uid, $gid, "$homedir/$file"; if ( $cnt != 1 ) { logging::logmsg(STDERR, "$name: FAILED to set perms on: $homedir/$file"); $retval = 0; } else { logging::logmsg(STDERR, "$name: Set permissions on $homedir/$file"); $retval = 1; } } logging::logmsg(STDERR, "$name: returning with value: $retval"); return ($retval); } From briank at kappacs.com Thu Dec 2 12:52:11 2010 From: briank at kappacs.com (Brian Katzung) Date: Thu, 02 Dec 2010 14:52:11 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> Message-ID: <4CF806FB.3020006@kappacs.com> This is less secure, but here's another thought: system("sudo /usr/sbin/useradd ..."); with useradd permission for Apache. I would probably go with the suid perl myself, depending on the purpose of the server, who else is also on the server, and whether the (virtual?) machine is dedicated to this service. - Brian On 2010-12-02 14:16, Young, Darren wrote: > I need some ideas on a problem I'm having doing mkdir and chown in Perl. The Perl script I have is running as a CGI under Apache 2.2.3 (RHEL). This script is the receiving end of a web service using SOAP::Lite (client is C# .NET). This script needs to do a mkdir for a user home directory and change permissions on it to that of the user (and their primary GID). > > Problem is Apache is running as the user "apache" (as it should) and therefore the script has no permissions do to a mkdir on /export/home. I haven't even gotten to the chown part, which if memory serves me correctly, won't work unless the script is being run as root. Can't change ownership of a directory to something other than yourself if you're not root right? > > I've considered the options of setuid-perl (argh), running the web server as something else (ugh) suexec under Apache or even setting the permissions on /export/home to that of apache. Though the latter won't solve the chown problem. > > Anyone have any other thoughts before I hang myself with setuid root? > > Darren Young > > Here's the worker code: > > ############################################################################### > # NAME : _make_homedir > # DESCRIPTION : Create a user home directory > # ARGUMENTS : string(username), string(uid), string(type) > # RETURN : 0 or 1 > # NOTES : > ############################################################################### > sub _make_homedir { > my ( $uname, $uid, $actype ) = @_; > my $name = "_make_homedir"; > logging::logmsg(STDERR, "$name: entering _make_homedirs()"); > > my $homedir = $config::GCH_HOMEDIR{$actype} . "/$uname"; > my @skelfiles = ( '.cshrc', '.login', '.profile' ); > my $skelbase = "$FindBin::Bin/skel"; > my $gid = $config::GCH_GID{$actype}; > my $retval = 1; > > ### Log the info > logging::logmsg(STDERR, "$name: homedir => $homedir"); > logging::logmsg(STDERR, "$name: skelbase => $skelbase"); > logging::logmsg(STDERR, "$name: gid => $gid"); > > ############################################################################## > ### Create the home directory > ############################################################################## > logging::logmsg(STDERR, "$name: Attempting to create directory: $homedir"); > if ( !-d $homedir ) { > if ( mkdir( "$homedir", 0720 ) ) { > logging::logmsg(STDERR, "$name: Created home directory: $homedir"); > } else { > my $err = "FAILED to create home directory $homedir: $!"; > logging::logmsg(STDERR, "$name: $err"); > die($err); > } > } else { > my $err = "FAILED to create directory $homedir: $homedir already exists"; > logging::logmsg(STDERR, "$name: $err"); > die("$err"); > } > > > ############################################################################## > ### Change the ownership on the home directory > ############################################################################## > logging::logmsg(STDERR, "$name: Attempting to change ownership on: $homedir"); > my $cnt = 0; > $cnt = chown $uid, $gid, $homedir; > if ( $cnt != 1 ) { > my $err = "FAILED - home directory $homedir ownership not changed: $!"; > logging::logmsg(STDERR, "$name: $err"); > die($err); > } else { > logging::logmsg(STDERR, "$name: $homedir ownership changed to $uid:$gid"); > $retval = 1; > } > > > ############################################################################## > ### Copy all the skel files and set their perms > ############################################################################## > foreach my $file (@skelfiles) { > if ( !copy( "$skeldir/$file", "$homedir" ) ) { > logging::logmsg(STDERR, "$name: FAILED to copy $skeldir/$file to $homedir"); > $retval = 0; > } else { > logging::logmsg(STDERR, "$name: Copied $skeldir/$file to $homedir"); > $retval = 1; > } > > $cnt = chown $uid, $gid, "$homedir/$file"; > if ( $cnt != 1 ) { > logging::logmsg(STDERR, "$name: FAILED to set perms on: $homedir/$file"); > $retval = 0; > } else { > logging::logmsg(STDERR, "$name: Set permissions on $homedir/$file"); > $retval = 1; > } > } > > logging::logmsg(STDERR, "$name: returning with value: $retval"); > return ($retval); > } > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- Brian Katzung, Kappa Computer Solutions, LLC Leveraging UNIX, GNU/Linux, open source, and custom software solutions for business and beyond Phone: 877.367.8837 x1 http://www.kappacs.com From Darren.Young at chicagobooth.edu Thu Dec 2 13:05:49 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Thu, 2 Dec 2010 21:05:49 +0000 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4CF806FB.3020006@kappacs.com> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11A1C3B@bushexmb01.gsb.uchicago.edu> > > This is less secure, but here's another thought: > > system("sudo /usr/sbin/useradd ..."); > > with useradd permission for Apache. The user is actually in AD (with POSIX extensions) so all I have to do here is mkdir and chown. > > I would probably go with the suid perl myself, depending on the purpose > of the server, who else is also on the server, and whether the > (virtual?) machine is dedicated to this service. > It's our grid front-end. I'm thinking I will just convert the SOAP::Lite script from a CGI to a Daemon, run it on port 8080 or something and put an IP acl on it. From briank at kappacs.com Thu Dec 2 13:54:25 2010 From: briank at kappacs.com (Brian Katzung) Date: Thu, 02 Dec 2010 15:54:25 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11A1C3B@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <4BD3751450A4DC43B6C2B43DD2BEF2E11A1C3B@bushexmb01.gsb.uchicago.edu> Message-ID: You could use usermod instead of useradd, but the daemon sounds like a good approach. - Brian "Young, Darren" wrote: >> >> This is less secure, but here's another thought: >> >> system("sudo /usr/sbin/useradd ..."); >> >> with useradd permission for Apache. > >The user is actually in AD (with POSIX extensions) so all I have to do >here is mkdir and chown. > >> >> I would probably go with the suid perl myself, depending on the >purpose >> of the server, who else is also on the server, and whether the >> (virtual?) machine is dedicated to this service. >> >It's our grid front-end. I'm thinking I will just convert the >SOAP::Lite script from a CGI to a Daemon, run it on port 8080 or >something and put an IP acl on it. >_______________________________________________ >Chicago-talk mailing list >Chicago-talk at pm.org >http://mail.pm.org/mailman/listinfo/chicago-talk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. From jtk at depaul.edu Thu Dec 2 15:09:28 2010 From: jtk at depaul.edu (John Kristoff) Date: Thu, 2 Dec 2010 17:09:28 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4CF806FB.3020006@kappacs.com> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> Message-ID: <20101202230928.GA1749@condor.depaul.edu> On Thu, Dec 02, 2010 at 02:52:11PM -0600, Brian Katzung wrote: > This is less secure, but here's another thought: > > system("sudo /usr/sbin/useradd ..."); > > with useradd permission for Apache. I think you'll also need to make sure sudo doesn't have 'requiretty' set, which is usually does by default. If you don't need it to be real time, another option is to have web script create a "config" file some place safe, such as a queue directory. External to your web server process you'd have some queue watcher come along and perform the actions on that config in the queue. John From Darren.Young at chicagobooth.edu Thu Dec 2 15:20:03 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Thu, 2 Dec 2010 23:20:03 +0000 Subject: [Chicago-talk] mkdir() question In-Reply-To: <20101202230928.GA1749@condor.depaul.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11A2138@bushexmb01.gsb.uchicago.edu> > I think you'll also need to make sure sudo doesn't have 'requiretty' > set, which is usually does by default. > > If you don't need it to be real time, another option is to have > web script create a "config" file some place safe, such as a queue > directory. External to your web server process you'd have some > queue watcher come along and perform the actions on that config > in the queue. That's basically what we used to do with cron jobs and text files. Requirement now is for real time instant gratification. Someone else's gratification, not mine, I might add. So far running it as a daemon is working well. CGI and admin stuff always was a pain, especially when root access is needed. I tried suexec as an experiment, it didn't like su'ing to root. I installed perl-setuid and set the script to be 4755 as a test. It didn't like my "use'ing" in our standard module kit. Daemon running as root it is. Port other than 80 and an IP access list on it to allow only 2 source IP's. From merlyn at stonehenge.com Thu Dec 2 15:25:01 2010 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Thu, 02 Dec 2010 15:25:01 -0800 Subject: [Chicago-talk] mkdir() question In-Reply-To: <20101202230928.GA1749@condor.depaul.edu> (John Kristoff's message of "Thu, 2 Dec 2010 17:09:28 -0600") References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> Message-ID: <868w0792r6.fsf@red.stonehenge.com> >>>>> "John" == John Kristoff writes: John> I think you'll also need to make sure sudo doesn't have 'requiretty' John> set, which is usually does by default. Odd, in my version of "man sudoers", I see: requiretty If set, sudo will only run when the user is logged in to a real tty. When this flag is set, sudo can only be run from a login session and not via other means such as cron(8) or cgi-bin scripts. This flag is off by default. Where have you been where it's been on by default? And in fact, it wasn't until I hit a system where I couldn't run "sudo foo" in a script that I even knew that there *was* such a dainbramaged option. :) I mean, if you care about ttys, you use a password. But a passwordless sudo invocation should *not* ever need a tty. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From lembark at wrkhors.com Thu Dec 2 19:59:12 2010 From: lembark at wrkhors.com (Steven Lembark) Date: Thu, 2 Dec 2010 21:59:12 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> Message-ID: <20101202215912.2ce84ea7lembark@wrkhors.com@wrkhors.com> On Thu, 2 Dec 2010 20:16:56 +0000 "Young, Darren" wrote: > Can't change ownership of a > directory to something other than yourself if > you're not root right? Depends on the O/S and parent dir mods. > I've considered the options of setuid-perl > (argh), running the web server as something > else (ugh) suexec under Apache or even setting > the permissions on /export/home to that of > apache. Though the latter won't solve the > chown problem. Write a daemon to monitor the directory and hack the mods for you. All it needs to do is scan /home for dir's that don't match their owner. The last one I wrote took about 15 linws of code with the curlys, if-ladder, and signal handlers for hup and term. > Anyone have any other thoughts before I hang > myself with setuid root? Please don't hang ypurself. -- Steven Lembark 3646 Flora Pl Workhorse Computing St Louis, MO 63110 lembark at wrkhors.com +1 888 359 3508 From Darren.Young at chicagobooth.edu Fri Dec 3 06:27:31 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Fri, 3 Dec 2010 14:27:31 +0000 Subject: [Chicago-talk] mkdir() question In-Reply-To: <20101202215912.2ce84ea7lembark@wrkhors.com@wrkhors.com> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <20101202215912.2ce84ea7lembark@wrkhors.com@wrkhors.com> Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11A27EF@bushexmb01.gsb.uchicago.edu> > > Anyone have any other thoughts before I hang > > myself with setuid root? > > Please don't hang ypurself. :-) From jtk at depaul.edu Fri Dec 3 09:10:54 2010 From: jtk at depaul.edu (John Kristoff) Date: Fri, 3 Dec 2010 11:10:54 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <868w0792r6.fsf@red.stonehenge.com> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> <868w0792r6.fsf@red.stonehenge.com> Message-ID: <20101203171054.GA9056@condor.depaul.edu> On Thu, Dec 02, 2010 at 03:25:01PM -0800, Randal L. Schwartz wrote: > Where have you been where it's been on by default? Good question. Odd, I've not used it much, but the few times I have had to it's been on CentOS systems. Looks like CentOS (or most likely whatever RedHat-based package they get it from) enables it by default. > I mean, if you care about ttys, you use a password. But a passwordless > sudo invocation should *not* ever need a tty. Indeed, it took me awhile to realize why my cron job wasn't working when I first ran into this. John From jtk at depaul.edu Fri Dec 3 09:19:47 2010 From: jtk at depaul.edu (John Kristoff) Date: Fri, 3 Dec 2010 11:19:47 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11A2138@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> <4BD3751450A4DC43B6C2B43DD2BEF2E11A2138@bushexmb01.gsb.uchicago.edu> Message-ID: <20101203171947.GB9056@condor.depaul.edu> On Thu, Dec 02, 2010 at 11:20:03PM +0000, Young, Darren wrote: > That's basically what we used to do with cron jobs and text files. > Requirement now is for real time instant gratification. Someone else's > gratification, not mine, I might add. Well, personally, I'm not sure I like the approach myself. In essence it is a form of polling, which seems sort of inelegant in a mainframe kind of way. :-) > Daemon running as root it is. Port other than 80 and an IP access > list on it to allow only 2 source IP's. There are at least a couple of Perl modules that provide what looks like a usable interface that may help. There is one named Sudo and another perhaps more interesting is IPC::ShellCmd. If you care enough to want to try avoid running as root that is. John From merlyn at stonehenge.com Fri Dec 3 09:45:34 2010 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Fri, 03 Dec 2010 09:45:34 -0800 Subject: [Chicago-talk] mkdir() question In-Reply-To: <20101203171054.GA9056@condor.depaul.edu> (John Kristoff's message of "Fri, 3 Dec 2010 11:10:54 -0600") References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> <868w0792r6.fsf@red.stonehenge.com> <20101203171054.GA9056@condor.depaul.edu> Message-ID: <86d3pi698h.fsf@red.stonehenge.com> >>>>> "John" == John Kristoff writes: John> On Thu, Dec 02, 2010 at 03:25:01PM -0800, Randal L. Schwartz wrote: >> Where have you been where it's been on by default? John> Good question. Odd, I've not used it much, but the few times I have John> had to it's been on CentOS systems. Looks like CentOS (or most likely John> whatever RedHat-based package they get it from) enables it by John> default. More reasons that RHEL is evil, I guess. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From clydeforrester at gmail.com Fri Dec 3 10:41:52 2010 From: clydeforrester at gmail.com (Clyde Forrester) Date: Fri, 03 Dec 2010 12:41:52 -0600 Subject: [Chicago-talk] mkdir() question In-Reply-To: <86d3pi698h.fsf@red.stonehenge.com> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> <868w0792r6.fsf@red.stonehenge.com> <20101203171054.GA9056@condor.depaul.edu> <86d3pi698h.fsf@red.stonehenge.com> Message-ID: <4CF939F0.9000204@gmail.com> Randal L. Schwartz wrote: >>>>>> "John" == John Kristoff writes: > > John> On Thu, Dec 02, 2010 at 03:25:01PM -0800, Randal L. Schwartz wrote: >>> Where have you been where it's been on by default? > > John> Good question. Odd, I've not used it much, but the few times I have > John> had to it's been on CentOS systems. Looks like CentOS (or most likely > John> whatever RedHat-based package they get it from) enables it by > John> default. > > More reasons that RHEL is evil, I guess. :) > I don't mean to be throwing gasoline on the fire here, but: Why would leaving a potential security exploit closed by default be considered "evil"? Or is a trade-off between security and [something you consider more valuable]? c4 From merlyn at stonehenge.com Fri Dec 3 10:54:30 2010 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Fri, 03 Dec 2010 10:54:30 -0800 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4CF939F0.9000204@gmail.com> (Clyde Forrester's message of "Fri, 03 Dec 2010 12:41:52 -0600") References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> <4CF806FB.3020006@kappacs.com> <20101202230928.GA1749@condor.depaul.edu> <868w0792r6.fsf@red.stonehenge.com> <20101203171054.GA9056@condor.depaul.edu> <86d3pi698h.fsf@red.stonehenge.com> <4CF939F0.9000204@gmail.com> Message-ID: <86k4jq4rh5.fsf@red.stonehenge.com> >>>>> "Clyde" == Clyde Forrester writes: Clyde> Why would leaving a potential security exploit closed by default Clyde> be considered "evil"? Because it's a false security. Either you should want a password, in which case, use it. Bingo, tty is required. Or you are operating passwordless, mostly likely for something in automation, and requiring a tty is just a nuisance. Where's the third case, where requiretty adds *any* security? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From tigerpeng2001 at yahoo.com Fri Dec 3 11:59:14 2010 From: tigerpeng2001 at yahoo.com (tiger peng) Date: Fri, 3 Dec 2010 11:59:14 -0800 (PST) Subject: [Chicago-talk] get array element from a function return Message-ID: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Hi, To get the weekday name of current day in Perl, I am using some thing like below. I do not like so many punctuation marks. Can it be simpler? perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")]->[[localtime(time)]->[6]]' -------------- next part -------------- An HTML attachment was scrubbed... URL: From imranjj at gmail.com Fri Dec 3 12:06:30 2010 From: imranjj at gmail.com (imran javaid) Date: Fri, 3 Dec 2010 14:06:30 -0600 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <647343.94726.qm@web120513.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Message-ID: perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]' On Fri, Dec 3, 2010 at 1:59 PM, tiger peng wrote: > Hi, > To get the weekday name of current day in Perl, I am using some thing like > below. I do not like so many punctuation marks. Can it be simpler? > > perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", > "Sat")]->[[localtime(time)]->[6]]' > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From jim at jimandkoka.com Fri Dec 3 12:09:39 2010 From: jim at jimandkoka.com (Jim Thomason) Date: Fri, 3 Dec 2010 14:09:39 -0600 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <647343.94726.qm@web120513.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Message-ID: To start with, you can just quote your list to get rid of your punctuation marks: perl -le 'print [qw(Sun Mon Tue Wed Thu Fri Sat)]->[[localtime(time)]->[6]]' And then drop the unnecessary refs and derefs: perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]' You could also use the fact that localtime in a scalar context returns the ctime value, which'll have the day as the first 3 characters. perl -le 'print substr(scalar(localtime),0,3)' But there may be some portability issues across different locales or languages... -Jim.... On Fri, Dec 3, 2010 at 1:59 PM, tiger peng wrote: > Hi, > To get the weekday name of current day in Perl, I am using some thing like > below. I do not like so many punctuation marks. Can it be simpler? > > perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", > "Sat")]->[[localtime(time)]->[6]]' > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From Darren.Young at chicagobooth.edu Fri Dec 3 12:09:00 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Fri, 3 Dec 2010 20:09:00 +0000 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <647343.94726.qm@web120513.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11A3012@bushexmb01.gsb.uchicago.edu> > Hi, > To get the weekday name of current day in Perl, I am using some thing like below. I do not like so many > punctuation marks. Can it be simpler? > > perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")]->[[localtime(time)]->[6]]' use POSIX qw(strftime); $wday = strftime "%a", localtime; print $wday . "\n"; From tigerpeng2001 at yahoo.com Fri Dec 3 12:13:29 2010 From: tigerpeng2001 at yahoo.com (tiger peng) Date: Fri, 3 Dec 2010 12:13:29 -0800 (PST) Subject: [Chicago-talk] get array element from a function return In-Reply-To: References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Message-ID: <694948.72996.qm@web120508.mail.ne1.yahoo.com> Thanks, What's wrong with command below? :) ls -l | perl -nle 'print (split)[0]' syntax error at -e line 1, near ")[" Execution of -e aborted due to compilation errors. ________________________________ From: imran javaid To: Chicago.pm chatter Sent: Fri, December 3, 2010 2:06:30 PM Subject: Re: [Chicago-talk] get array element from a function return perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]' On Fri, Dec 3, 2010 at 1:59 PM, tiger peng wrote: > Hi, > To get the weekday name of current day in Perl, I am using some thing like > below. I do not like so many punctuation marks. Can it be simpler? > > perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", > "Sat")]->[[localtime(time)]->[6]]' > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn.c.carroll at gmail.com Fri Dec 3 12:16:45 2010 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Fri, 3 Dec 2010 14:16:45 -0600 Subject: [Chicago-talk] get array element from a function return In-Reply-To: References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> Message-ID: $ perl -MPOSIX=strftime -e 'print strftime "%a", localtime()' Fri shawn.c.carroll at gmail.com Perl Programmer Soccer Referee On Fri, Dec 3, 2010 at 14:09, Jim Thomason wrote: > To start with, you can just quote your list to get rid of your > punctuation marks: > > perl -le 'print [qw(Sun Mon Tue Wed Thu Fri Sat)]->[[localtime(time)]->[6]]' > > And then drop the unnecessary refs and derefs: > > perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]' > > You could also use the fact that localtime in a scalar context returns > the ctime value, which'll have the day as the first 3 characters. > > perl -le 'print substr(scalar(localtime),0,3)' > > But there may be some portability issues across different locales or > languages... > > -Jim.... > > On Fri, Dec 3, 2010 at 1:59 PM, tiger peng wrote: >> Hi, >> To get the weekday name of current day in Perl, I am using some thing like >> below. I do not like so many punctuation marks. Can it be simpler? >> >> perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", >> "Sat")]->[[localtime(time)]->[6]]' >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From michael at potter.name Fri Dec 3 15:54:39 2010 From: michael at potter.name (Michael Potter) Date: Fri, 3 Dec 2010 18:54:39 -0500 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <694948.72996.qm@web120508.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> <694948.72996.qm@web120508.mail.ne1.yahoo.com> Message-ID: What are you trying to do? Does this help: ls -l | perl -nle 'print ((split)[0])' The parens are being seen at the attached to the print, rather than wrapping the split. On Fri, Dec 3, 2010 at 3:13 PM, tiger peng wrote: > Thanks, > > What's wrong with command below? > > :) ls -l | perl -nle 'print (split)[0]' > syntax error at -e line 1, near ")[" > Execution of -e aborted due to compilation errors. > > > ________________________________ > From: imran javaid > To: Chicago.pm chatter > Sent: Fri, December 3, 2010 2:06:30 PM > Subject: Re: [Chicago-talk] get array element from a function return > > perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]' > > On Fri, Dec 3, 2010 at 1:59 PM, tiger peng wrote: >> Hi, >> To get the weekday name of current day in Perl, I am using some thing like >> below. I do not like so many punctuation marks. Can it be simpler? >> >> perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", >> "Sat")]->[[localtime(time)]->[6]]' >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From chicago.pm at galumph.com Fri Dec 3 16:39:30 2010 From: chicago.pm at galumph.com (Elliot Shank) Date: Fri, 03 Dec 2010 18:39:30 -0600 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <694948.72996.qm@web120508.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> <694948.72996.qm@web120508.mail.ne1.yahoo.com> Message-ID: <4CF98DC2.5090900@galumph.com> On 12/3/10 2:13 PM, tiger peng wrote: > Thanks, > > What's wrong with command below? > > :) ls -l | perl -nle 'print (split)[0]' > syntax error at -e line 1, near ")[" > Execution of -e aborted due to compilation errors. It's because print is being interpreted as a function, i.e. you're attempting to put a subscript after "print (split)". If the first significant thing after "print" or "say" is an opening parenthesis, then the function grabs that before anything else in the statement. For example, say ("blah"), "lah"; will only emit "blah" even though say "blah", ("lah") will emit "blahlah". From michael at potter.name Fri Dec 3 15:49:24 2010 From: michael at potter.name (Michael Potter) Date: Fri, 3 Dec 2010 18:49:24 -0500 Subject: [Chicago-talk] mkdir() question In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11A18E4@bushexmb01.gsb.uchicago.edu> Message-ID: On Thu, Dec 2, 2010 at 3:16 PM, Young, Darren wrote: > I need some ideas on a problem I'm having doing mkdir and chown in Perl. The Perl script I have is running as a CGI under Apache 2.2.3 (RHEL). This script is the receiving end of a web service using SOAP::Lite (client is C# .NET). This script needs to do a mkdir for a user home directory and change permissions on it to that of the user (and their primary GID). > Here is an idea, I have not thought this all the way thru, but maybe it will inspire: How about building a .tar file with the starter files. gtar has so many options perhaps there is an option to create the directory while untaring and perhaps set the user. You will still need to run as root, but perhaps the command you need to run as root will be less hackable. good luck, -- Michael Potter From imranjj at gmail.com Fri Dec 3 12:56:16 2010 From: imranjj at gmail.com (imran javaid) Date: Fri, 3 Dec 2010 14:56:16 -0600 Subject: [Chicago-talk] get array element from a function return In-Reply-To: <694948.72996.qm@web120508.mail.ne1.yahoo.com> References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> <694948.72996.qm@web120508.mail.ne1.yahoo.com> Message-ID: > What's wrong with command below? > > :) ls -l | perl -nle 'print (split)[0]' > syntax error at -e line 1, near ")[" > Execution of -e aborted due to compilation errors. Try this: ls -l | perl -nle 'print [split]->[0]' or ls -l | perl -nle 'split; print @_[0]' I think "split" does not like being unassigned. it will in that case assign the return to @_. -imran From shlomif at iglu.org.il Sat Dec 4 02:10:04 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Sat, 4 Dec 2010 12:10:04 +0200 Subject: [Chicago-talk] get array element from a function return In-Reply-To: References: <647343.94726.qm@web120513.mail.ne1.yahoo.com> <694948.72996.qm@web120508.mail.ne1.yahoo.com> Message-ID: <201012041210.04931.shlomif@iglu.org.il> On Saturday 04 December 2010 01:54:39 Michael Potter wrote: > What are you trying to do? > > Does this help: > ls -l | perl -nle 'print ((split)[0])' > ?ls -l | perl -nle 'print +(split)[0]'? will also work. Also see the -a and -F options to Perl. Regards, Shlomi Fish > The parens are being seen at the attached to the print, rather than > wrapping the split. > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What does "Zionism" mean? - http://shlom.in/def-zionism She's a hot chick. But she smokes. She can smoke as long as she's smokin'. Please reply to list if it's a mailing list post - http://shlom.in/reply . From jjacobus at ponyx.com Mon Dec 13 11:19:06 2010 From: jjacobus at ponyx.com (Jim Jacobus) Date: Mon, 13 Dec 2010 13:19:06 -0600 Subject: [Chicago-talk] Reading cookies in wrong domain with raw_fetch Message-ID: I ran into a problem using raw_fetch CGI::Cookie; which I'm not sure how to resolve. I have a few forms on my website which uses cookies to preserve user items like name, address, etc. These are stored in cookies on their browser. As you all know one attribute of cookies is the domain name. I've run into a problem when reading and storing cookies because the domain is different if the user uses an url of "http://www.mydomian.com" or "http://mydomain.com" I ended up with duplicate cookie names with different information since the domain names were different. If I force the cookie to be written with the domain ".mydomain.com", it's not read if they link using "http://mydomain.com". If I hard code the cookie domain to be "mydomain.com", I can't read if they link using "http://www.mydomain.com". Is there a way raw_fetch can read the "other" domain's cookies? The only solution I've been able to come up with is creating/updating two cookies with different domains (which is just stupid). JJ From brian.d.foy at gmail.com Tue Dec 14 23:53:03 2010 From: brian.d.foy at gmail.com (brian d foy) Date: Wed, 15 Dec 2010 01:53:03 -0600 Subject: [Chicago-talk] Who wants to see Tron as soon as possible? Message-ID: Tron: Legacy starts at 12:01 am on Friday (which most people, including movie theaters, consider Thursday night). Who wants to see it with me at that time at AMC River East (since they sell advance tickets), which has it in 3D (not counting the neglected fourth dimension that is the difference between films and still pictures)? I bought my tickets through MovieTickets.com. I know midnight is a bit late for some of you poor wage slaves, but sometimes you have to live a little, or at least call in sick for a friday. If any of you work in a place of decent technology, just saying "It's frickin' Tron!" should be enough to get the next day off. If you work at a really cool place, your boss will probably come with you. If you're Elliot, your boss is probably reserving the entire theatre. Here's how you can spend the rest of your time that Thursday evening: * take a nap after work. * 7:30pm-ish, snacks, etc and a viewing of the original Tron at my place (sadly, Rogers Park) * 11pm-ish shift closer to theater by going to the Billy Goat for those who want to meet up later * 12:01am: the movie * Billy Goat again to discuss how much the movie sucked compared the the totally awesome original And, remember, if you see it right away, you'll be able to tweet and poke and yelp about how much it sucks as earlier as possible. You'll be 3l33t, etc, and you can spoil it for all your co-workers who had to be responsible and what not. If you are one of those Tron cosplay people, just meet us at the theater. :) -- brian d foy http://www.pair.com/~comdog/ From richard at rushlogistics.com Tue Dec 21 08:29:46 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 21 Dec 2010 11:29:46 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?pass_a_scalar_from_procmail_to_perl=3F?= Message-ID: <20101221162947.15CCB106@captain.xo.com> I am struggling to get the procmail recipe below to pass the subject to my perl script as a scalar. Everything seems to work accept $SUBJECT does not get passed. Can anyone help? Thanks, Richard :0 * ^FROM:.* * ^Subject:[ ]*\/[^ ].* { SUBJECT=$MATCH } :0 * ? perl -e 'require "/home/richard/.pmdir/test_subject.pl"; test_subj("$SUBJECT");' -- Richard Reina Rush Logistics, Inc. Watch our 3 minute movie: http://www.rushlogistics.com/movie From frag at ripco.com Tue Dec 21 09:09:30 2010 From: frag at ripco.com (Mike Fragassi) Date: Tue, 21 Dec 2010 11:09:30 -0600 (CST) Subject: [Chicago-talk] =?utf-8?q?pass_a_scalar_from_procmail_to_perl=3F?= In-Reply-To: <20101221162947.15CCB106@captain.xo.com> References: <20101221162947.15CCB106@captain.xo.com> Message-ID: I suspect that $SUBJECT is being passed in as an environment variable. In other words, it'd be like the difference between these 2 command lines: SUBJECT=Foo perl -e 'print $ENV{SUBJECT}' vs. SUBJECT=Foo perl -e 'print $SUBJECT' So try $ENV{SUBJECT} instead of $SUBJECT. If that doesn't work, it might be quoting: you may need to use double-quotes around the command after the -e. > * ? perl -e 'require "/home/richard/.pmdir/test_subject.pl"; test_subj("$SUBJECT");' -- Mike F. From richard at rushlogistics.com Tue Dec 21 10:02:10 2010 From: richard at rushlogistics.com (richard at rushlogistics.com) Date: Tue, 21 Dec 2010 18:02:10 +0000 Subject: [Chicago-talk] pass a scalar from procmail to perl? Message-ID: <158983212-1292954531-cardhu_decombobulator_blackberry.rim.net-2109554528-@bda2142.bisx.prod.on.blackberry> Mike to the rescue! That worked like a charm. Thank you very much. If I ever make it to PM meeting I seriously owe you a beer. Thanks again, Richard ------Original Message------ From: Mike Fragassi Sender: chicago-talk-bounces+richard=rushlogistics.com at pm.org To: Chicago.pm chatter ReplyTo: Chicago.pm chatter Subject: Re: [Chicago-talk]pass a scalar from procmail to perl? Sent: Dec 21, 2010 11:09 AM I suspect that $SUBJECT is being passed in as an environment variable. In other words, it'd be like the difference between these 2 command lines: SUBJECT=Foo perl -e 'print $ENV{SUBJECT}' vs. SUBJECT=Foo perl -e 'print $SUBJECT' So try $ENV{SUBJECT} instead of $SUBJECT. If that doesn't work, it might be quoting: you may need to use double-quotes around the command after the -e. > * ? perl -e 'require "/home/richard/.pmdir/test_subject.pl"; test_subj("$SUBJECT");' -- Mike F. _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk Watch our 3 minute movie: http://www.rushlogistics.com/movie From frag at ripco.com Tue Dec 21 15:48:06 2010 From: frag at ripco.com (Mike Fragassi) Date: Tue, 21 Dec 2010 17:48:06 -0600 (CST) Subject: [Chicago-talk] pass a scalar from procmail to perl? In-Reply-To: <158983212-1292954531-cardhu_decombobulator_blackberry.rim.net-2109554528-@bda2142.bisx.prod.on.blackberry> References: <158983212-1292954531-cardhu_decombobulator_blackberry.rim.net-2109554528-@bda2142.bisx.prod.on.blackberry> Message-ID: On Tue, 21 Dec 2010, richard at rushlogistics.com wrote: > Mike to the rescue! That worked like a charm. Thank you very much. If > I ever make it to PM meeting I seriously owe you a beer. You're welcome! And I guess this raises the question of when we will have the next PM meeting. (Next week, or January?) And the questions about PM meetings in general. In 2011, is anyone interested in giving a talk? Does anyone here even have a place downtown where a talk could be given? - Mike. From richard at rushlogistics.com Fri Dec 24 07:05:00 2010 From: richard at rushlogistics.com (richard at rushlogistics.com) Date: Fri, 24 Dec 2010 15:05:00 +0000 Subject: [Chicago-talk] Capturing a perl scripts return value in procmail? Message-ID: <50987966-1293203097-cardhu_decombobulator_blackberry.rim.net-1392513889-@bda2142.bisx.prod.on.blackberry> The line below executes a perl script in my procmail recipe. I was hoping someone would be able to tell me how to capture the return value from it so I can use it for further testing? * ? perl -e 'require "/home/richard/.pmdir/test_subject.pl"; test_subj("$SUBJECT");' Watch our 3 minute movie: http://www.rushlogistics.com/movie From Andy_Bach at wiwb.uscourts.gov Fri Dec 24 08:38:05 2010 From: Andy_Bach at wiwb.uscourts.gov (Andy_Bach at wiwb.uscourts.gov) Date: Fri, 24 Dec 2010 10:38:05 -0600 Subject: [Chicago-talk] Capturing a perl scripts return value in procmail? In-Reply-To: <50987966-1293203097-cardhu_decombobulator_blackberry.rim.net-1392513889-@bda2142.bisx.prod.on.blackberry> References: <50987966-1293203097-cardhu_decombobulator_blackberry.rim.net-1392513889-@bda2142.bisx.prod.on.blackberry> Message-ID: >From this: http://partmaps.org/era/procmail/quickref.html Test exit code of external program * ? shell command (pipeline) The program gets the current processed message as its standard input (but is of course free to ignore it); the condition is successful if the program returns a zero exit code. If the command is a pipeline with several commands in it, the exit code is whatever the last program in the pipeline returns (at least on systems worthy of the Unix name). Messages printed to standard error by the pipeline are displayed in the log. ... Variables Curiously, even those special pseudovariables which are primarily useful for their associated side effects (LOG, SHIFT, etc) can be referenced, so you can see what the last value you assigned to them was. This is only marginally useful for most of us, but comes as a pleasant surprise in situations where this is actually useful. and the return value is in: The exit code of a program called up by Procmail is in $? If you want more, perhaps, this FAQ suggests: http://partmaps.org/era/procmail/mini-faq.html More-complicated conditions can also be exit codes of other shell scripts or programs, or tests against the full body of the message, or against Procmail variables (Procmail's variables are also exported to the environment of subprocesses, so they are essentially environment variables. There are details about this later in this FAQ.) You can put them in %ENV and have procmail ref them as $ In the following example, we are grabbing the contents of the Subject: header into the variable SUBJECT, and then pass that in as the -s option of our-script. SUBJECT=`formail -zxSubject:` :0w: | our-script -s "$SUBJECT" >>output ---------------------- Andy Bach Systems Mangler Internet: andy_bach at wiwb.uscourts.gov Voice: (608) 261-5738; Cell: (608) 658-1890 "A witty saying proves nothing." --Voltaire -------------- next part -------------- An HTML attachment was scrubbed... URL: From Darren.Young at chicagobooth.edu Fri Dec 24 09:39:34 2010 From: Darren.Young at chicagobooth.edu (Young, Darren) Date: Fri, 24 Dec 2010 17:39:34 +0000 Subject: [Chicago-talk] HTML Parsing Message-ID: <4BD3751450A4DC43B6C2B43DD2BEF2E11EFF02@bushexmb01.gsb.uchicago.edu> I have HTML that contains a table that I need to extract fields from. In the end I want to take this data and shove it in a MySQL table but CSV in the interim would suffice. HTML::Parser and HTML::TreeBuilder appear like they can do this but does anyone know any "simpler" modules for this? It's been a long while since I tried this type of thing. Oh, content is coming from LWP's $res->content. Thanks in advance, Darren From richard at rushlogistics.com Fri Dec 24 10:05:00 2010 From: richard at rushlogistics.com (richard at rushlogistics.com) Date: Fri, 24 Dec 2010 18:05:00 +0000 Subject: [Chicago-talk] Capturing a perl scripts return value inprocmail? In-Reply-To: References: <50987966-1293203097-cardhu_decombobulator_blackberry.rim.net-1392513889-@bda2142.bisx.prod.on.blackberry> Message-ID: <2095602661-1293213895-cardhu_decombobulator_blackberry.rim.net-2016385473-@bda2142.bisx.prod.on.blackberry> Andy, Thanks very much for your reply? I really appreciate especially since it's more a procmail question than a perl question. However if I may, could I clarify and ask if the return value is in $? how can I test it's value? I want to do: If return value equals 1 Do this Else Do something else Thanks again and please pardon me all for asking a question that is only tangentialy related to perl. I promise if I figure it out I'll go back to baking cookies with my family. Watch our 3 minute movie: http://www.rushlogistics.com/movie -----Original Message----- From: Andy_Bach at wiwb.uscourts.gov Sender: chicago-talk-bounces+richard=rushlogistics.com at pm.org Date: Fri, 24 Dec 2010 10:38:05 To: Chicago.pm chatter Reply-To: "Chicago.pm chatter" Subject: Re: [Chicago-talk] Capturing a perl scripts return value in procmail? _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From shlomif at iglu.org.il Sat Dec 25 02:30:49 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Sat, 25 Dec 2010 12:30:49 +0200 Subject: [Chicago-talk] HTML Parsing In-Reply-To: <4BD3751450A4DC43B6C2B43DD2BEF2E11EFF02@bushexmb01.gsb.uchicago.edu> References: <4BD3751450A4DC43B6C2B43DD2BEF2E11EFF02@bushexmb01.gsb.uchicago.edu> Message-ID: <201012251230.49637.shlomif@iglu.org.il> Hi Darren, On Friday 24 December 2010 19:39:34 Young, Darren wrote: > I have HTML that contains a table that I need to extract fields from. In > the end I want to take this data and shove it in a MySQL table but CSV in > the interim would suffice. HTML::Parser and HTML::TreeBuilder appear like > they can do this but does anyone know any "simpler" modules for this? It's > been a long while since I tried this type of thing. > Well, http://search.cpan.org/dist/HTML-TableExtract/ has a good reputation and good reviews on CPAN (and quite a few open bugs which indicate people actually tried to use it.). If that fails, you should try http://search.cpan.org/dist/HTML-TreeBuilder-LibXML/ , while not "simpler" than plain HTML::TreeBuilder, it is more powerful and also gives you XPath and other nice features. > Oh, content is coming from LWP's $res->content. > I think both modules should be able to handle these fine. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/ Chuck Norris can make the statement "This statement is false" a true one. Please reply to list if it's a mailing list post - http://shlom.in/reply . From richard at rushlogistics.com Mon Dec 27 08:13:00 2010 From: richard at rushlogistics.com (Richard Reina) Date: Mon, 27 Dec 2010 11:13:00 -0500 (EST) Subject: [Chicago-talk] help with system call Message-ID: <20101227161300.C0D5B1C58@alexander.xo.com> I am trying to incorporate ripmime into my perl script to extract (one message at a time) the attachments from email messages. The problem I am having is that, though I have searched extensively, I cannot find a ripmime option that allows me to rename the file to a name provided by the script ($id_number). So I figure I need to get perl to rename the file (attachment) for me but I don't know it's current name? The ripmime man pages say there are not any environment variables --if that matters?. What I need is for the extracted attachment to take on the name of $id_number. what I have so far: sub strip_attachments { my ($id_number) = @_; #strip the attachment off the lone email waiting in mail_with_atchmnt system("ripmime -i /home/richard/mail/.inboxes/mail_with_atchmnt -v -d /home/richard/attachments/"); } # end of sub Any help would be greatly appreciated. Thanks, Richard -- Richard Reina Rush Logistics, Inc. Watch our 3 minute movie: http://www.rushlogistics.com/movie From frag at ripco.com Mon Dec 27 11:25:28 2010 From: frag at ripco.com (Mike Fragassi) Date: Mon, 27 Dec 2010 13:25:28 -0600 (CST) Subject: [Chicago-talk] help with system call In-Reply-To: <20101227161300.C0D5B1C58@alexander.xo.com> References: <20101227161300.C0D5B1C58@alexander.xo.com> Message-ID: With the caveat that I had never heard of ripmime before 10 minutes ago, here's what you could do: have the $id_number be name of a directory that you pass to -d, e.g. something like /home/richard/attachments/$id. mkdir() this directory[*], and if that succeeded, then run ripmime with -d $id_dir. When ripmime is finished and assuming it reports no errors, rename the files in $id_dir to whatever you want, with the id number. If that leaves $id_dir empty, rmdir() it. [*] Or better still, use File::Path's make_path() -- Mike. From kent at c2group.net Mon Dec 27 12:18:56 2010 From: kent at c2group.net (Kent Cowgill) Date: Mon, 27 Dec 2010 15:18:56 -0500 Subject: [Chicago-talk] help with system call In-Reply-To: References: <20101227161300.C0D5B1C58@alexander.xo.com> Message-ID: <3C9301B1-D353-4B59-A8BB-3FE43075D3D8@c2group.net> Better than that, use a perl module from cpan to parse out your mime attachments. Wish I could recall the one I've used with great success in the past, but I'm away from a computer and snowed in at the moment, so I can't http://search.cpan.org .