[23021] in Perl-Users-Digest
Perl-Users Digest, Issue: 5241 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 19 14:05:57 2003
Date: Sat, 19 Jul 2003 11:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 19 Jul 2003 Volume: 10 Number: 5241
Today's topics:
Re: "use" remote modules? <l.tierney@btinternet.com>
Re: Code to put today's date into MM-DD-YY format <mpapec@yahoo.com>
Re: Code to put today's date into MM-DD-YY format <REMOVEsdnCAPS@comcast.net>
Re: Converting Perl5 into Perl4 <REMOVEsdnCAPS@comcast.net>
Re: Error upon Error... nobull@mail.com
Re: How can I delete files useing Perl <me@privacy.net>
Re: How can I delete files useing Perl <jurgenex@hotmail.com>
Re: How can I delete files useing Perl <jwillmore@cyberia.com>
Re: JOIN problem ? (2nd attempt to post) <REMOVEsdnCAPS@comcast.net>
Re: need 2 digit dd/mm output <REMOVEsdnCAPS@comcast.net>
Notepad Bug when editing Perl scripts in Win XP? <cry-ofan@mylinuxisp.com>
Re: OT: You should really use the ISO date format (YYYY <abigail@abigail.nl>
Re: perlstyles <mpapec@yahoo.com>
Re: perlstyles <mpapec@yahoo.com>
Re: priority queue <jwillmore@cyberia.com>
Re: regl expression <REMOVEsdnCAPS@comcast.net>
Re: Running CGI through browser from local hard disk <wsegrave@mindspring.com>
Re: s there a module to acess Micorsoft Access datafile <jwillmore@cyberia.com>
Re: s there a module to acess Micorsoft Access datafile <stanb@panix.com>
Re: s there a module to acess Micorsoft Access datafile <wsegrave@mindspring.com>
Re: sinfo script, xchat, slackware <asu1@c-o-r-n-e-l-l.edu>
Re: sinfo script, xchat, slackware (Lukas Mai)
Re: sinfo script, xchat, slackware <asu1@c-o-r-n-e-l-l.edu>
Re: Taint Mode Newbie Help (Jay Tilton)
Re: Taint Mode Newbie Help (sekdab)
Re: Variable definition help needed <REMOVEsdnCAPS@comcast.net>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 19 Jul 2003 17:51:24 +0100
From: lawrence tierney <l.tierney@btinternet.com>
Subject: Re: "use" remote modules?
Message-Id: <bfbsue$i9h$1$8302bc10@news.demon.co.uk>
Hello again,
After reading your post and the "require" docs I came up with the following:
#! /usr/bin/perl -w
use strict;
push @INC,\&get_remote_module('remote_module.pm');
my $password=password(); # password() located in remote_module.pm
print qq/"$password"\n/;
sub get_remote_module{
require LWP::Simple;
my $name='http://www.remotehost.org/cgi-bin/'.pop;
my $doc=LWP::Simple::get($name) or return;
open(my($fh),"<:scalar",\$doc) or die 'urg!';
return $fh;
}
### END CODE ###
But it doesn't work. Notes:
1. The call to remote_module hook in @INC works.
2. The LWP::Simple call works.
3. If I dump out $doc after the LWP::Simple call it is indeed the module I
want, containing sub password.
4. Filehandle opens successfully
Script dies however on the password() call with
"Undefined subroutine &main::password called........"
I also tried, in vain:
$password=remote_module::password();
but this died a similar death.
I've spent an hour or so on it and am stumped. I get the feeling I'm missing
something really obvious like a reference/derefence etc.
Help?
------------------------------
Date: Sat, 19 Jul 2003 14:33:13 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Code to put today's date into MM-DD-YY format
Message-Id: <58eihv4glq4j9shb0ilkr0ebreqcj2k0jv@4ax.com>
X-Ftn-To: Ron
"Ron" <his_ron@yahoo.com> wrote:
>I am new to cgi I would like to place a check box on my form. When it is
>checked & I run my custom Upload cgi script I would like this code to.
>
>1. Get the current date & day of the week.
>2. Put it into this format MM-DD-YY Day
>
>I have no ideal where to start. Suggestions Please?
my($dd,$mm,$yy,$day) = (localtime)[3,4,5,6];
my $today = join '-', map sprintf("%02d", $_), ($mm+1,$dd,$yy%100);
$day = (qw/Sun Mon Tue Wed Thu Fri Sat/)[$day];
print "$today $day\n";
--
Matija
------------------------------
Date: Sat, 19 Jul 2003 08:05:45 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Code to put today's date into MM-DD-YY format
Message-Id: <Xns93BD5C7A4CC8Bsdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Ron" <his_ron@yahoo.com> wrote in news:dwVRa.85021$hV.5878942
@twister.austin.rr.com:
> I am new to cgi I would like to place a check box on my form. When it is
> checked & I run my custom Upload cgi script I would like this code to.
>
> 1. Get the current date & day of the week.
> 2. Put it into this format MM-DD-YY Day
>
> I have no ideal where to start. Suggestions Please?
Use my new Time::Format module, available on CPAN and at ActiveState's
repository:
use Time::Format;
$string = $time{'mm-dd-yy Day'};
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxlCFGPeouIeTNHoEQKenwCfY3y57SQxb4qHYSlWEZu6IVyG5g0An3aV
Ls/K8ETz9fYfMQraNX7DJxmr
=CF5O
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 10:07:09 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Converting Perl5 into Perl4
Message-Id: <Xns93BD710E641DEsdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
kielhd@freenet.de (kielhd) wrote in news:10a4173d.0307172145.565b55c2
@posting.google.com:
> Hi NG,
>
> Sometimes I need to convert a script written in Perl5 into Perl4.
> As this is a boring and very time-consuming task, I am looking for a
> way to automate this.
> Are there tools available for this job?
Somebody out there is still using version 4?? Wow.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxleh2PeouIeTNHoEQLjPwCg8F70LYXtJ4aGWD0hxjbWsNwZ3nMAoPWW
yY4MmHJdvGLijOw1p+TtEZRi
=aeqL
-----END PGP SIGNATURE-----
------------------------------
Date: 19 Jul 2003 09:52:09 -0700
From: nobull@mail.com
Subject: Re: Error upon Error...
Message-Id: <4dafc536.0307190852.715fd6d7@posting.google.com>
unix@att.com (rab) wrote in message news:<9bb5fc.0307170934.23230501@posting.google.com>...
> > >>>>> "rab" == rab <unix@att.com> writes:
> >
> > rab> anyone seen this error before:
[ apparent file not found loading a DLL ]
> > This does look puzzling. If the files truly exist, could there be a
> > permission issue with DB_File.sl? It could be the result of a bad
> > install, so you might try re-installing the DB_File modules.
> Ethan....Thanks for the response. Checked the permissions...but they
> were all fine.
>
> I'm afraid that reinstalling is even more difficult. I wouldn't even
> know where to begin trying to get rid of all the complaints from gcc.
Both thes possibly point to the same underlying problem - you have a
problem with your compiler and/or it's associated libraires. In many
architectures I believe the dl_ functions in the C RTL need to load
some soet of helper library before the library you've asked to load.
I suspect it is this library that's missing, incorrectly protected, or
in the wrong place.
Try doing a system-call trace to see what underlying system call it is
that is returning the error. On some Unicies a system call trace is
called "strace".
> I got this copy of Perl from a port to HPUX site.
^^^^
How is that pronounced? :-)
------------------------------
Date: Sat, 19 Jul 2003 22:37:18 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: How can I delete files useing Perl
Message-Id: <bfb6u4$d752m$1@ID-172104.news.uni-berlin.de>
"moneytea" <moneytea@xinhuanet.com> wrote in message
news:bfb2kd$271k$1@mail.cn99.com...
> Hi,
> I am a newbie,I try to use this programs to delete files(OS is Linux)
> ----------------------------------------
> # file DEL.pl
> #!/usr/bin/perl
> $readparse;
> print "Content-type: text/html\n\n";
> unlink "del_file";
> ----------------------------------------
> I can execute this program in command line ( ./DEL.pl) then it works .and
> the file "del_file"
> was removed ,but when I put "DEL.pl" into the /usr/local/apache/cgi-bin/
,It
> do nothing.
Oh but it will do something if you inspect the reason it "do nothing", ie:
unlink "del_file" or die "Could not delete del_file because $!\n";
and I'm willing to say with 99% certainity that the reason will be "No such
file or directory"
------------------------------
Date: Sat, 19 Jul 2003 12:07:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How can I delete files useing Perl
Message-Id: <_vaSa.43877$kI5.36320@nwrddc02.gnilink.net>
moneytea wrote:
[...]
> I can execute this program in command line ( ./DEL.pl) then it works
> .and the file "del_file"
> was removed ,but when I put "DEL.pl" into the
> /usr/local/apache/cgi-bin/ ,It do nothing.
> I really do not understand.
> I even try this : system ("rm -rf del_file") ,not work too!
> this program has the popedom of root.
> Can anyone help me ?
Please see "perldoc -q 500".
Although that FAQ seems to answer a different question, the answer applies
in your case, too.
jue
------------------------------
Date: Sat, 19 Jul 2003 17:37:42 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: How can I delete files useing Perl
Message-Id: <20030719133603.485201f3.jwillmore@cyberia.com>
> I can execute this program in command line ( ./DEL.pl) then it works
> .and the file "del_file"
> was removed ,but when I put "DEL.pl" into the
> /usr/local/apache/cgi-bin/ ,It do nothing.
> I really do not understand.
> I even try this : system ("rm -rf del_file") ,not work too!
> this program has the popedom of root.
There are a variety of reasons why your code does not work when run
through the server - most if not all are not Perl related (ie suexec
in Apache - which prevents scripts from doing such a thing). Check
your server logs (ie the error log in Apache) to what what message is
issued from the script. Testing at the command line for this script
may not give the whole picture.
More on the Perl side - you can include the following to aid in
debugging a buggy CGI script
use CGI::Carp qw(fatalsToBrowser);
This line sends fatal errors to the browser (as well as the error log)
so you can see 'live and in person' what the error was.
HTH
Jim
------------------------------
Date: Sat, 19 Jul 2003 07:02:52 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <Xns93BD51D11A55Esdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
stuseven@hotmail.com (stu7) wrote in
news:d7dd90b0.0307181714.647d57b4@posting.google.com:
> Jeff 'japhy' Pinyan <pinyaj@rpi.edu> advised...
>
>> First of all, join() returns a scalar. Why are you storing ONE
>> scalar in an array? It's not "wrong", it's just suspect. I don't
>> think you're doing what you think you're doing.
>>
>> Second, you've left out the first argument to join(), which is the
>> string with which to join the other strings.
>>
>> print join " -- ", qw( apple banana cherry );
>> # apple -- banana -- cherry
>
> *** Ya... I had not read about this first argument to JOIN...
> *** thanks to pinyaj and the others who told me about overlooking this
> *** Saving to an array was my natural instinct, given the original
> *** list of three... a simple scalar would certainly be a good
> *** suggestion here instead.
Just a friendly tip: Please don't start every line of your post with
"***" or any other character. Longstanding Usenet tradition is that you
precede text lines with one or more characters like that when you're
quoting someone else's text. Many newsreader programs highlight text
differently if there's a leading string like your "***". I had to read
your article twice to find your response.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxkzWGPeouIeTNHoEQI4SgCfUyiKy/p2/gwCBaszRO7NGCgErtMAn0T9
RR5vzhu/02SiEJsfRGipAoSd
=49+l
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 07:09:17 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: need 2 digit dd/mm output
Message-Id: <Xns93BD52E76B928sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Bob" <rpl-erroroneous@goldengate.net> wrote in
news:3f17f31a$0$100$8f4e7992@newsreader.goldengate.net:
> need to have host get date and use in outputfile name. mon and day
> has to be two digits.
> ex: spc20030702.kdg
>
> ex:
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime(time);
> print "spc$year$mon$mday.kdg\n";
>
> results in: spc2003718.kdg and I need spc20030718.kdg
> thanks
Use my new Time::Format module (available on CPAN, and from ActiveState's
repository).
use Time::Format;
$filename = "spc$time{yyyymmdd}.kdg";
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxk00WPeouIeTNHoEQL2GwCfXI0I2VDpqyw7scFEFAf8zPmo0qsAoJUv
FKAz2L3BTmABrBesMaAJ22/O
=gHa7
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 11:03:33 -0500
From: randy <cry-ofan@mylinuxisp.com>
Subject: Notepad Bug when editing Perl scripts in Win XP?
Message-Id: <ssqihvo46u10f343qdapm8j21uhaheq6mp@4ax.com>
Has anyone else tried editing perl scripts in notepad in XP? I am
getting some characters inserted into the scripts.....
-------------
-Randy
------------------------------
Date: 19 Jul 2003 11:19:14 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OT: You should really use the ISO date format (YYYY-MM-DD)
Message-Id: <slrnbhia9i.t0h.abigail@alexandra.abigail.nl>
Julian Mehnle (julian@mehnle.net) wrote on MMMDCVIII September MCMXCIII
in <URL:news:bfa0vr$cnjmo$1@ID-65075.news.uni-berlin.de>:
-- Ron wrote:
-- > 1. Get the current date & day of the week.
-- > 2. Put it into this format MM-DD-YY Day
--
-- On an off-topic note: you should really use the internationally
-- standardized ISO date format[1], which is YYYY-MM-DD. Most other date
-- formats, like MM-DD-YY, are either confusing or ambiguous, or both.
To be pedantic, there isn't a "the ISO date format". There are
several formats. 8 digits, 7 digits, 6 digits, etc. With or without
dashes. W's and T's can be thrown in, for even more digits.
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Sat, 19 Jul 2003 14:33:11 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: perlstyles
Message-Id: <ngeihv0a00bfh9h4ig09mm9st2f09e4epm@4ax.com>
X-Ftn-To: Janek Schleicher
"Janek Schleicher" <bigj@kamelfreund.de> wrote:
>> input (use of map/grep BLOCK is intentional to avoid distracting
>> commas & parentheses)...
>>
>> @arr = join ',' , map { s/'/\\'/g; "'$_'" }
> ^^
>
>That is very different from the OP's &&.
>In your solution, every element of the array is mapped into enclosing
>single quotes, while in the OP's code, an element is only enclosed by
>single quotes if there had been any single quote inside the element
>before.
>I don't know whether it is a problem for the OP, but at least, it's a
>little difference
Guilty as charged, parv correctly recognized what I was trying to do with
map.
--
Matija
------------------------------
Date: Sat, 19 Jul 2003 14:33:12 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: perlstyles
Message-Id: <98cihv068gfi11jqnu997e6inprjsmeklr@4ax.com>
X-Ftn-To: Janek Schleicher
"Janek Schleicher" <bigj@kamelfreund.de> wrote:
>> laziness), but that's just me.
>>
>> #1
>> @arr = join ',', map s|'|\\'|g && "'$_'", grep /^MB/, @arr;
> ^^^^ ^^^^
>
>An array
> result is a string!
Ack.
>> #2
>> @arr = join(',', map(s|'|\\'|g && "'$_'", grep(/^MB/, @arr)));
>
>I wouldn't look so much to the brackets regarding for code maintainers.
>It is easy and simple to understand that both lines
>do a comma-join over all transformed elements of @arr that starts with MB.
>
>What is hard to understand on the first view is the transformation that
>has to be done. You first need to think some seconds only to comprehend it. And
>even if you did it, you can't be sure whether the implemented algorithm
>was also the intended one. That is dangerous for maintainance.
>
>I think it would be better to write a subroutine doing exactly this
>transformation. If the subroutine has a sensful name, the maintainer can
>read and understand without any thinking what the line does. In addition,
>he/she can decide whether the transformation does what the subroutine name
>says or a completely different transformation will be needed instead.
Subroutine is ok, but I'll be rather using it in case when it's more complex
or if it's needed on more then one place in script. map with block braces
comes very handy here.
>Let's say something like:
>
>sub escape_single_quotes($) {
> my $string = shift;
> $string =~ s,',\\',g
> and return qq/'$string'/
> or return $string;
>}
>
>my $str = join ",", map escape_single_quotes($_), grep /^MB/, @arr;
>
>
>Note, that I also did two other slight changes.
>First I changed the pipe symbol to a comma in the substitution.
>Not that the comma is so much better, but IMHO the pipe is that worse,
>as it is also the alternation operator with such a special meaning in
>substitutions, that it is very confusing (and thus less readable) if it
>is used as delimiters in regexps.
I prefer ! or | as delimiters in simple regex as they stand vertical(that
depends mostly on which key is nearer to punch :))
>Second I wrote "'$string'" as qq/'$string'/. I wanted to emphasize that
>the returned value is in principle the '$string' in contrast to the simple
>$string. I prefer not to have "' or '" in a text as single and double
>quotes look similar and are hard to distinguish if they are very near in
>the next. (But that's perhaps more a personal style than a hard
>maintainance demand)
>
>
>> and another one, how do you prefer $h{key} over $h{'key'} in case where key
>> is strictly English \w class?
>
>Both doesn't matter for readability and maintainance. I, personally, wouldn't write
>$h{'key'} where it isn't necessary (main reason is laziness),
>but both ways are easy to read, understand and change.
Most of the time they are, but did you have a chance to see something like
this? :-)
"sql stuff.. values ('$h{'key1'}','$h{'key2'}','$h{'key3'}',...)"
--
Matija
------------------------------
Date: Sat, 19 Jul 2003 17:49:34 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: priority queue
Message-Id: <20030719134756.08ee33b1.jwillmore@cyberia.com>
> I am trying to implement a priority queue where people will
> submit some
> job through cgi written in perl and then another independent perl
> script will clear the queue. Different submitter has different
> priority. What's the best way to implement a global queue that can
> be accessed by the cgi and the perl script concurrently? We cannot
> use database though.
Yes, you can - if you want. You can use the DBI module and the module
DBD::CSV.
A few warnings:
1) it's CSV, so you'll get some slow performance (versus a RDBMS).
2) depending on how much you want to queue, size becomes an issue
(you may wind up with a rather large CSV file that takes up a lot of
space and requires higher maintainence versus a RDBMS)
3) to date, from my understanding, the DBD::CSV module implements a
lot of SQL-92 statements, but not all. It should provide enough that
you can
implement a pretty slick system.
If this is going to be a 'batch proccessing' type set up, you may want
to think about the CSV approach. So, you can do such wonderful things
as create job dependencies and run conditions for the job queue.
Just a though or two ...
Jim
------------------------------
Date: Sat, 19 Jul 2003 10:03:06 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: regl expression
Message-Id: <Xns93BD705F02181sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"bruno_storz" <bruno_storz@gmx.de> wrote in news:bf8pmn$nj9$07$1@news.t-
online.com:
> Hi there,
>
> I wonder, why this reg. expression does not replace this:
>
> $line = "<title><!-- HTML_titel --></title>";
> $html{'titel'} = "my Titel";
> $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
The x modifier changed the way spaces are interpreted in regular
expressions. Why do you have it there?
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxldlWPeouIeTNHoEQLQZwCgzWrG9WEOlezA0KUp073CW34/YzAAoIs9
tjRALrK6lvgKbf7lo6QNy7fJ
=5PNc
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 07:53:00 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bfbf52$pom$1@slb6.atl.mindspring.net>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3f18eb11@news.victoria.tc.ca...
<snip>
> Something in our setups must be different then.
>
> I have opened many files (i.e. local files, e.g. C:\try.htm) with MSIE of
> various versions, and have not found that mime like headers at the top of
> the file make any difference to the display, except as appearing as lines
> of text at the top of the window.
>
Well, yes. That was exactly my point. The text I did not wish to appear at
the top of the HTML displayed in the (MSIE5.5) browser was the Content-Type
header, e.g., for the script fragment I posted,
Content-Type: text/html; charset=ISO-8859-1
Note that this is not a problem in a CGI environment; but rather, is only a
problem when generating the HTML from the command line. Indeed, the
Content-Type header *must* be present in the CGI environment. Without it, we
get an "Internal Server Error" message in the browser window.
Malcolm, I think we are in agreement. As these issues are off-topic for
clpm, we could leave the thread here (or move it to ciwac, where IMO, it
*should* have been posted).
Cheers.
Bill Segraves
------------------------------
Date: Sat, 19 Jul 2003 15:11:26 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <20030719110411.3e407099.jwillmore@cyberia.com>
> I find myself with the eed to obtain some data stored in Microsoft
> Access format files from a perl script ruinning on a FreebSD box.
>
> What's the best way to do this?
Use the appropriate DBD (aka Database Driver) that is used by the DBI
module (aka Database Interface Module).
>
> The files are actually on a Windows machien, but I can mount the
> partiton using Samba.
There is one issue to be addressed here - Access is NOT an RDBMS -
like MySQL, PostgreSQL, or Oracle. It "lives" on a local machine (aka
no ports/sockets are opened to allow for remote access to the database
file). So, the issue is first - "How do I in FreeBSD 'talk' ODBC?".
You need to use an application that will 'talk' ODBC - such as
UnixODBC. For more information about ODBC datasources and available
ports, check the FreeBSD website or your local FreeBSD newsgroup.
A way to get around the ODBC issue is to (depending on the size,
structure, etc) convert the Access database into a CSV file and use
the DBD::CSV module (or other CSV modules, or just 'roll your own') to
access the file. I suggest this because you mention you can mount the
Windows partition on your FreeBSD box. If the Access database is
small, converting to CSV should not be a problem. Then, using the DBI
module and the CSV driver, you could use the file as a 'real'
database, complete with using SQL to select, update, delete, etc. Not
the most efficient solution, but it is a solution.
Another way to do it is to install Perl on the Windows machine (since
it's a separate box) and then use DBI::Proxy. This will allow you to
set up an ODBC DSN on the Windows box and allow the FressBSD box to
'connect' to the DSN. I can't say I've done it, but have read about
this as a solution.
One last solution is to take the database in Access and move it into
an RDBMS (such as MySQL or PostgreSQL - which FreeBSD has ports for
both). Then you could use Perl's DBI module and the appropriate DBD
module to access the database.
HTH
Jim
------------------------------
Date: Sat, 19 Jul 2003 15:54:55 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bfbpkf$38t$1@reader1.panix.com>
In <20030719110411.3e407099.jwillmore@cyberia.com> James Willmore <jwillmore@cyberia.com> writes:
>> I find myself with the eed to obtain some data stored in Microsoft
>> Access format files from a perl script ruinning on a FreebSD box.
>>
>> What's the best way to do this?
>Use the appropriate DBD (aka Database Driver) that is used by the DBI
>module (aka Database Interface Module).
>>
>> The files are actually on a Windows machien, but I can mount the
>> partiton using Samba.
>There is one issue to be addressed here - Access is NOT an RDBMS -
>like MySQL, PostgreSQL, or Oracle. It "lives" on a local machine (aka
>no ports/sockets are opened to allow for remote access to the database
>file). So, the issue is first - "How do I in FreeBSD 'talk' ODBC?".
>You need to use an application that will 'talk' ODBC - such as
>UnixODBC. For more information about ODBC datasources and available
>ports, check the FreeBSD website or your local FreeBSD newsgroup.
>A way to get around the ODBC issue is to (depending on the size,
>structure, etc) convert the Access database into a CSV file and use
>the DBD::CSV module (or other CSV modules, or just 'roll your own') to
>access the file. I suggest this because you mention you can mount the
>Windows partition on your FreeBSD box. If the Access database is
>small, converting to CSV should not be a problem. Then, using the DBI
>module and the CSV driver, you could use the file as a 'real'
>database, complete with using SQL to select, update, delete, etc. Not
>the most efficient solution, but it is a solution.
>Another way to do it is to install Perl on the Windows machine (since
>it's a separate box) and then use DBI::Proxy. This will allow you to
>set up an ODBC DSN on the Windows box and allow the FressBSD box to
>'connect' to the DSN. I can't say I've done it, but have read about
>this as a solution.
>One last solution is to take the database in Access and move it into
>an RDBMS (such as MySQL or PostgreSQL - which FreeBSD has ports for
>both). Then you could use Perl's DBI module and the appropriate DBD
>module to access the database.
I'm reading (perhaps incorectly) in what you are saying that thee is no
Windows way of providing a n ODBC server on the windows side, with the
access database as a data source.
Is this correct?
If not, could I not do this, and use DBI::ODBC?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Sat, 19 Jul 2003 12:27:18 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bfbv5j$4tv$1@slb9.atl.mindspring.net>
"Stan Brown" <stanb@panix.com> wrote in message
news:bfbpkf$38t$1@reader1.panix.com...
writes:
<snip>
> I'm reading (perhaps incorectly) in what you are saying that thee is no
> Windows way of providing a n ODBC server on the windows side, with the
> access database as a data source.
>
> Is this correct?
>
> If not, could I not do this, and use DBI::ODBC?
Hi, Stan.
If you have access to a Win32 computer:
1. "Start + Settings + Control Panel" and look for "ODBC Data Sources
(32bit)".
2. Open it and go to the "System DSN" tab.
3. Add a System Data Source with the Microsoft Access Driver (*.mdb), giving
it the name of the Access file you wish to use.
Now you should be able to use DBI::ODBC to make a connection to the Win32
box that has the Access file on it.
Cheers.
Bill Segraves
------------------------------
Date: 19 Jul 2003 12:28:27 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: sinfo script, xchat, slackware
Message-Id: <Xns93BD56352E50Casu1cornelledu@132.236.56.8>
NeoSadist <neosad1st@charter.net> wrote in
news:vhhklek8hg12cf@corp.supernews.com:
> Sorry to post about this, but i think it's related to the way
> perl works.
>
> I have a problem with perl reading a file right when i make a
> call of the script inside xchat. It's the sinfo script. I verified
> that the output is wrong (i.e. read the file it's supposed to get the
> info from, "cat /proc/meminfo"). However, I don't know perl much,
> although i'm familiar with basic (so i'm not a complete moron lol).
>
> Here is the module in question. Anyone, please help me get it
> working right. Your help will be "rewarded" by putting your name in
> the script and on the website i'm going to offer the revision to.
>
> sub mem {
> if (@resources){
> } else {
> @resources = cat("/proc/meminfo");
> }
Do you get an error "Undefined subroutine &main::cat called at c.pl" for
the line above? I think you need to use the backtick operator here. Or, you
could just open the file and read from it.
Since I do nothave access to a Linux system, I copied the contents you gave
to a local file called meminfo, and used the following script:
#! C:/Perl/bin/perl.exe -w
use diagnostics;
use strict;
use warnings;
# You are probably better off just opening this file rather than using a
# shell command
my @res = `cat meminfo`;
# Since you seem to go through quite a few lines to parse the contents,
# I thought I would show how to parse it into a hash. I guess (from your
# code) that this is not necessary for some versions of the system.
my %res;
foreach (@res) {
if(/(\w+):\s+(\d+)/) {
$res{$1} = $2;
}
}
printf "Memory Usage: %.1f/%.1f MB (%.0f%%)",
($res{'MemTotal'} - $res{'MemFree'})/1024,
$res{'MemTotal'}/1024,
(($res{'MemTotal'} - $res{'MemFree'})/$res{'MemTotal'})*100;
__END__
C:\Home> c.pl
Memory Usage: 412.2/978.0 MB (42%)
Alternatively,
#! C:/Perl/bin/perl.exe -w
use diagnostics;
use strict;
use warnings;
my %res;
open MEMINFO, "< meminfo" || die "Cannot open meminfo: $!\n";
while(<MEMINFO>) {
if(/(\w+):\s+(\d+)/) {
$res{$1} = $2;
}
}
close MEMINFO;
printf "Memory Usage: %.1f/%.1f MB (%.0f%%)",
($res{'MemTotal'} - $res{'MemFree'})/1024,
$res{'MemTotal'}/1024,
(($res{'MemTotal'} - $res{'MemFree'})/$res{'MemTotal'})*100;
__END__
C:\Home> d.pl
Memory Usage: 412.2/978.0 MB (42%)
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 19 Jul 2003 09:45:47 -0700
From: .lmai@web.de (Lukas Mai)
Subject: Re: sinfo script, xchat, slackware
Message-Id: <951cf24.0307190845.7ecb9184@posting.google.com>
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:
>
> Alternatively,
>
> #! C:/Perl/bin/perl.exe -w
>
> use diagnostics;
> use strict;
> use warnings;
Why -w, then?
>
> my %res;
>
> open MEMINFO, "< meminfo" || die "Cannot open meminfo: $!\n";
open(MEMINFO, "< meminfo") || die "Cannot open meminfo: $!\n";
or
open MEMINFO, "< meminfo" or die "Cannot open meminfo: $!\n";
HTH, Lukas
------------------------------
Date: 19 Jul 2003 16:54:36 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: sinfo script, xchat, slackware
Message-Id: <Xns93BD835577CE0asu1cornelledu@132.236.56.8>
.lmai@web.de (Lukas Mai) wrote in news:951cf24.0307190845.7ecb9184
@posting.google.com:
> "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:
>>
>> Alternatively,
>>
>> #! C:/Perl/bin/perl.exe -w
>>
>> use diagnostics;
>> use strict;
>> use warnings;
>
> Why -w, then?
>
>>
>> my %res;
>>
>> open MEMINFO, "< meminfo" || die "Cannot open meminfo: $!\n";
>
> open(MEMINFO, "< meminfo") || die "Cannot open meminfo: $!\n";
> or
> open MEMINFO, "< meminfo" or die "Cannot open meminfo: $!\n";
Sorry. Typing early in the morning.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Sat, 19 Jul 2003 11:15:12 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Taint Mode Newbie Help
Message-Id: <3f192827.208495935@news.erols.com>
seldan@lore.cc (sekdab) wrote:
: if ( $pass =~ /^[A-Za-z0-9]+$/ ) {
: $pass = $1;
# snip
: }
: I check to ensure that it is alphanumeric and then assign it to $1.
: After which, I place it in the shell execution backticks. However,
: both $1 and $pass are null now, and the execution fails.
$1 does not get defined unless there is a set of capturing parentheses
in the regex.
if ( $pass =~ /^([A-Za-z0-9]+)$/ ) {
$pass = $1;
# snip
}
------------------------------
Date: 19 Jul 2003 08:41:50 -0700
From: seldan@lore.cc (sekdab)
Subject: Re: Taint Mode Newbie Help
Message-Id: <4b21880f.0307190741.16899df2@posting.google.com>
Hi all.
Okay.. I posted the previous question half asleep after working on
this for awhile. My apologies. I'm going to try and rephrase this
now that I've had (a lot) of coffee :-).
I've written a CGI script that allows a user to change his/her Apache
password by calling "htpasswd -b" from the shell. The script runs
without any trouble. However, when I add the -T (taint) option, it
dies.
I have been trying to untaint this but have had no luck. I've read
'perlsec' and followed the example, but just can't get this to go.
I'm new at all of this, so am probably missing something obvious, but
if anyone could help, that'd be great. The working code is posted
below, without taint enabled. A basic outline is:
-Define modules and variables
-Subroutine for HTML Header
-Subroutine for HTML Table
-Call Subroutines to create HTML
-*** Validate User Input *** <--- This is the area which I can't
figure out.
What I do here is...
1) Ensure that values are not null
2) Ensure that the re-enter password matches the first one
3) Ensure that the data being passed to `` is alphanumeric
4) Ensure that htpasswd -b ran okay
-Call HTML Footer
It is fairly obvious that the $pass variable is the one being tainted.
It is received from the user via a form and then passed to a shell.
So, what I've been trying to do is untaint it. I've tried stuff
like...
$pass = $1;
after the if logic. That takes away the taint within the backticks,
but sets $pass to undefined. I'm utterly confused :-(. Thanks for
any help that can be given. The code, in its entirety, is posted
below:
Regards,
Tom
=======================CODE BELOW=========================
#!/opt/perl/bin/perl -w
use strict;
use CGI;
my $q=new CGI;
my $pass=$q->param("pass");
my $pass_ck=$q->param("pass_ck");
my $user=$q->remote_user;
my $pcmd='/opt/apache/bin/htpasswd -b';
my $auth='/usa/auth/passwd';
$ENV{PATH}='/usr/bin';
# Subroutine - HTML Header Information
sub create_header {
print $q->header,
$q->start_html(
-Title=>'U.S.A.',
-Style=>{-src=>'/css/stylesheet.css'} ),
$q->start_form(-method=>'post', -action=>'change_pass.pl');
}
# Subroutine - HTML Table Information
sub create_table {
print $q->table(
$q->Tr( [
$q->th( {-colspan=>2}, ['Password Administration'] ),
$q->td( ['Enter Your New Password',
$q->password_field(-Name=>'pass', -maxlength=>8) ] ),
$q->td( ['Reenter Your New Password',
$q->password_field(-Name=>'pass_ck', -maxlength=>8) ] ),
$q->td( [$q->submit,$q->button({-Name=>'Close Window',
-onclick=>'window.close()'} ) ] )
] )
);
}
# Subroutine - HTML Footer
sub create_footer {
print $q->end_form, $q->end_html;
}
# Load Header And Table
create_header();
create_table();
#---------------------------------
# *** Verify User Input ***
#---------------------------------
if ( $pass && $pass_ck ) {
if ( $pass eq $pass_ck ) {
if ( $pass =~ /^[A-Za-z0-9]+$/ ) {
my $output=`$pcmd $auth $user $pass 2>&1`;
chomp($output);
if ( $output eq "Updating password for user $user" ) {
print "<script>window.location.href='/pass_okay.html'</script>";
} else {
print "<script>window.location.href='/pass_error.html'</script>";
}
} else {
print "<script>window.location.href='/pass_invalid.html'</script>";
}
} else {
print "<script>window.location.href='/pass_nomatch.html'</script>";
}
}
# Load Footer
create_footer();
#========================END OF CODE========================
seldan@lore.cc (sekdab) wrote in message news:<4b21880f.0307182353.1e150296@posting.google.com>...
> Hello all.
>
> I am teaching myself Perl and have written a CGI script that allows a
> user to change his/her Apache password by calling "htaccess" in batch
> mode via a set of backticks (intranet only!).
>
> The script is running perfectly, however, I'd really like to place it
> in taint mode so that I can learn the right way. However, when I do
> that, it breaks. Here is a snippet where things go amiss:
>
> $!/opt/perl/bin/perl -wT
> use strict;
> use CGI;
> my $pass=$q->param("pass");
> my $pass_ck=$q->param("pass_ck");
> my $user=$q->remote_user;
> my $pcmd='/opt/apache/bin/htpasswd -b';
> my $auth='/usa/auth/passwd';
> $ENV{PATH}='/usr/bin';
>
> #... - Subroutines to Create HTML Snipped out - ...#
>
> if ( $pass && $pass_ck ) {
> if ( $pass eq $pass_ck ) {
> if ( $pass =~ /^[A-Za-z0-9]+$/ ) {
> $pass = $1;
> my $output=`$pcmd $auth $user $pass 2>&1`;
> chomp($output);
> if ( $output eq "Updating password for user $user" ) {
> print "PASSWORD CHANGE OKAY";
> } else {
> print "ERROR CHANGING PASSWORD";
> }
> } else {
> print "PASSWORD FAILED - NON ALPHANUMERIC";
> }
> } else {
> print "PASSWORDS DO NOT MATCH";
> }
> }
>
> The form is basically, "enter new password," "enter new password
> again," and "submit." So, first I ensure that the passwords entered
> are not null, and then verify that they match. After that (the third
> if) I try to untaint the $pass variable.
>
> I check to ensure that it is alphanumeric and then assign it to $1.
> After which, I place it in the shell execution backticks. However,
> both $1 and $pass are null now, and the execution fails.
>
> The error coming from Perl is:
>
> "Use of uninitialized value in concatenation (.) or string at
> /usa/perl/change_pass.pl line 67."
>
> That line is where I declare and set $ouput (i.e. the backtick
> execution).
>
> I'm stumped. I really want to learn this the right way first time
> around and get things working with taint. I love the concept behind
> it, just having trouble with the implementation.
>
> My appreciation for any assistance,
> Tom
------------------------------
Date: Sat, 19 Jul 2003 08:03:53 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Variable definition help needed
Message-Id: <Xns93BD5C2994B36sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Anthony Litton" <me@privacy.net> wrote in
news:bf93o1$cegm1$1@ID-168665.news.uni-berlin.de:
> OK, this is in reference to my CgiComments problem, which asked for
> help on on the 16th. The following lines are at the beginning of the
> script:
>
> my($cgiquery) = new CGI;
> my($blog_id) = $cgiquery->param('blog_id');
>
> 'blog_id' is an eighteen digit number, and for some reason I'm having
> problems creating correctly named files. The final digit is always 0,
> mysteriously. Would it be possible for me to define $blog_id as being
> only the first seventeen, or sixteen digits of 'blog_id'?
Before you put a band-aid on the problem, perhaps you should investigate
why the last digit is "mysteriously" always 0. Perhaps at some point along
the way, the id is being interpreted as a string, causing some precision to
be lost? If so, simply truncating your string is not going to be a good
solution.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxlBpWPeouIeTNHoEQJAKACg1G3LYqcpk/m6djWIdmDNadWcxMcAnAz8
XE8NhsmaLwLftckqQ3+aRKr6
=AYlA
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5241
***************************************