[28747] in Perl-Users-Digest
Perl-Users Digest, Issue: 10111 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 2 21:06:57 2007
Date: Tue, 2 Jan 2007 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 2 Jan 2007 Volume: 10 Number: 10111
Today's topics:
Re: dynamically loading perl modules (Marc Espie)
File::Temp and external editor <binand@gmx.net>
Re: File::Temp and external editor xhoster@gmail.com
How can i stop a module nicely? <spam.meplease@ntlworld.com>
Re: How can i stop a module nicely? <glex_no-spam@qwest-spam-no.invalid>
Re: How can i stop a module nicely? <jgibson@mail.arc.nasa.gov>
how to test uninitialized value <oxnard@carolina.rr.com>
Re: how to test uninitialized value <john@castleamber.com>
Re: Net::Telnet and Tk prevent Perl from returning syst <gorbachev3@comcast.net>
New modules: Plugins, SyslogScan::Daemon::* <muir@idiom.com>
POE-Component-IRC & whois <mail_nospam@domain.com>
Re: POE-Component-IRC & whois <DJStunks@gmail.com>
Re: POE-Component-IRC & whois <mail_nospam@domain.com>
printing long decimal numbers (Mark Hobley)
Problematic Perl code <mfarid1@yahoo.com>
Re: Problems with use locale and regexp (on aioe)
ReadKey compile error <Peter_W_Levine@uhc.com>
Re: ReadKey compile error <sisyphus1@nomail.afraid.org>
Re: Regular Expression <john@castleamber.com>
system command won't run with -T option on rallabs@adelphia.net
Re: system command won't run with -T option on <mritty@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 2 Jan 2007 23:41:19 +0000 (UTC)
From: espie@lain.home (Marc Espie)
Subject: Re: dynamically loading perl modules
Message-Id: <eneqiv$1ofu$1@biggoron.nerim.net>
You might wish to look at how existing perl frameworks do it.
For instance, Catalyst has some very extensive plugin support...
------------------------------
Date: Tue, 02 Jan 2007 22:07:08 +0100
From: Binand Sethumadhavan <binand@gmx.net>
Subject: File::Temp and external editor
Message-Id: <4vvvrsF1d1gauU1@mid.individual.net>
Hi All,
I am writing a program which:
- creates a temporary file using File::Temp
- opens the file in an external editor
- processes the data the user enters in the file
(sort of like "cvs commit" - it opens a /bin/vi buffer where you can
enter the commit log).
I cannot figure out how to get the text typed in the buffer, back in my
perl code. Here is what I'm doing at the moment:
$prefix = "/tmp";
$cmd = "/bin/vi";
use File::Temp qw/tempfile/;
($fh, $filename) = tempfile(DIR => $prefix, UNLINK => 1);
print $fh <<EOF;
[some pre-filled information here]
EOF
$mtime1 = (stat($filename))[9];
system ("$cmd $filename");
$mtime2 = (stat($filename))[9];
if ($mtime2 - $mtime1 > 0) {
# Process the contents of $filename here
}
What I am doing at the moment is @cmdbuf = `cat $filename`; so that I
can continue with the rest of my code, but I'd like to know how to do it
better.
I hope this is not a faq.
Binand
------------------------------
Date: 02 Jan 2007 21:48:20 GMT
From: xhoster@gmail.com
Subject: Re: File::Temp and external editor
Message-Id: <20070102164845.611$fH@newsreader.com>
Binand Sethumadhavan <binand@gmx.net> wrote:
> Hi All,
>
> I am writing a program which:
>
> - creates a temporary file using File::Temp
> - opens the file in an external editor
> - processes the data the user enters in the file
>
> (sort of like "cvs commit" - it opens a /bin/vi buffer where you can
> enter the commit log).
>
> I cannot figure out how to get the text typed in the buffer, back in my
> perl code.
What exactly is the problem?
>
> $prefix = "/tmp";
> $cmd = "/bin/vi";
> use File::Temp qw/tempfile/;
> ($fh, $filename) = tempfile(DIR => $prefix, UNLINK => 1);
> print $fh <<EOF;
> [some pre-filled information here]
> EOF
> $mtime1 = (stat($filename))[9];
> system ("$cmd $filename");
> $mtime2 = (stat($filename))[9];
> if ($mtime2 - $mtime1 > 0) {
> # Process the contents of $filename here
> }
I see no reason you need the $mtime stuff. What if the person edits
and saves the file really quickly?
> What I am doing at the moment is @cmdbuf = `cat $filename`; so that I
> can continue with the rest of my code, but I'd like to know how to do it
> better.
What is suboptimal about the way you are doing it now? We can't tell you
how to do it better if you don't tell us what the criteria are. I guess
for you could change @cmdbuf=`cat $filename` to something from File::Slurp,
for portability.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 2 Jan 2007 13:37:37 -0800
From: "doolittle" <spam.meplease@ntlworld.com>
Subject: How can i stop a module nicely?
Message-Id: <1167773857.314621.140340@n51g2000cwc.googlegroups.com>
Hello,
I would like to exit from my perl module, transferring control to the
calling program. Can this be done directly from an arbitrary subroutine
in the module?
eg
progam.pl:
use mymodule;
my $errror = mymodule::doSomething();
if ($error) { print 'error' }
...
-------------
mymodule.pm:
sub doSomething { doOne() }
sub doOne {
my $error = 1;
if ($error) {
# code to return directly to program.pl
}
}
1
------------------
So what can i replace '# code to return directly to program.pl' with so
that progam.pl prints
error
?
Die and Croak are too drastic, as they stop perl, and I don't want to
return an error up from doOne because it gets called from all over
mymodule.pm, deep within the program.
Any suggestions? Is it time i learnt about fork?
Thanks
------------------------------
Date: Tue, 02 Jan 2007 16:24:58 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How can i stop a module nicely?
Message-Id: <459adb24$0$497$815e3792@news.qwest.net>
doolittle wrote:
> Hello,
>
> I would like to exit from my perl module, transferring control to the
> calling program. Can this be done directly from an arbitrary subroutine
> in the module?
>
> eg
>
> progam.pl:
>
> use mymodule;
I know this is an example, however avoid using lowercase module names.
>
> my $errror = mymodule::doSomething();
> if ($error) { print 'error' }
> ...
>
> -------------
>
> mymodule.pm:
>
> sub doSomething { doOne() }
>
> sub doOne {
> my $error = 1;
> if ($error) {
> # code to return directly to program.pl
> }
> }
>
> 1
>
> ------------------
>
> So what can i replace '# code to return directly to program.pl' with so
> that progam.pl prints
>
> error
perldoc -f return
Since you have
if ($error) { print 'error' }
Then $error needs to be True ( e.g. 1 ), so you could
return 1;
> Die and Croak are too drastic, as they stop perl, and I don't want to
> return an error up from doOne because it gets called from all over
> mymodule.pm, deep within the program.
>
> Any suggestions? Is it time i learnt about fork?
No, however if you knew about fork you'd know that's not at all related
to handling errors, instead learn about handling exceptions/errors
correctly using eval.
perldoc -f eval
Then your code would be
> sub doOne {
> my $error = 1;
> if ($error) {
die "Hey there's an error in doOne";
> }
> }
eval {
mymodule::doSomething();
# ... lots of other code can be here...
};
if( $@ )
{
print "The error was $@";
}
The die is "caught" and the program will continue unless you exit/die in
the above if().
------------------------------
Date: Tue, 02 Jan 2007 14:24:41 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How can i stop a module nicely?
Message-Id: <020120071424411592%jgibson@mail.arc.nasa.gov>
In article <1167773857.314621.140340@n51g2000cwc.googlegroups.com>,
doolittle <spam.meplease@ntlworld.com> wrote:
> Hello,
>
> I would like to exit from my perl module, transferring control to the
> calling program. Can this be done directly from an arbitrary subroutine
> in the module?
Yes, with the return statement.
>
> eg
>
> progam.pl:
>
> use mymodule;
>
> my $errror = mymodule::doSomething();
> if ($error) { print 'error' }
> ...
>
> -------------
>
> mymodule.pm:
>
> sub doSomething { doOne() }
>
> sub doOne {
> my $error = 1;
> if ($error) {
> # code to return directly to program.pl
return $error;
> }
> }
>
> 1
>
> ------------------
>
> So what can i replace '# code to return directly to program.pl' with so
> that progam.pl prints
>
> error
>
> ?
>
> Die and Croak are too drastic, as they stop perl, and I don't want to
> return an error up from doOne because it gets called from all over
> mymodule.pm, deep within the program.
The calling program can trap a die statement by putting the call in an
eval block. You will have to decide how to treat errors in your own
methods that call doOne. Each method in your module should signal an
error condition to its caller. The primary choices are using die (or
croak), warn (or carp), or returning an error flag. The caller must
know which to be expected and handle the possible error appropriately.
If you want to make everybody happy, you can let the caller decide what
kind of error handling: e.g., set a flag to die if an error occurs.
>
> Any suggestions? Is it time i learnt about fork?
Have each method do its own error handling, report the error to its
caller consistently, and document the return values and possible side
effects.
I don't see how fork will help error handling.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Tue, 2 Jan 2007 20:14:50 -0500
From: "Oxnard" <oxnard@carolina.rr.com>
Subject: how to test uninitialized value
Message-Id: <459b038b$0$5281$4c368faf@roadrunner.com>
How do I test to see if a variable is initialized or not?
------------------------------
Date: 3 Jan 2007 01:33:04 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: how to test uninitialized value
Message-Id: <Xns98ACC6E1DA94castleamber@130.133.1.4>
"Oxnard" <oxnard@carolina.rr.com> wrote:
> How do I test to see if a variable is initialized or not?
perldoc -f defined
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Tue, 2 Jan 2007 18:48:10 -0500
From: "Alex Gorbachev" <gorbachev3@comcast.net>
Subject: Re: Net::Telnet and Tk prevent Perl from returning system commands on Windows
Message-Id: <dM-dnTQAts2jcgfYnZ2dnUVZ_oernZ2d@comcast.com>
FYI, ActiveState logged a bug on this, the bug can be tracked at
http://bugs.activestate.com/show_bug.cgi?id=65304
"Marc Dashevsky" <usenet@MarcDashevsky.com> wrote in message
news:MPG.20046d0b22bb82dd989b76@news.supernews.com...
> In article <a8idnRiQR_D0PQfYnZ2dnUVZ_q-vnZ2d@comcast.com>,
> gorbachev3@comcast.net says...
>> Unfortunately no improvement. It seems something in the code of
>> Net::Telnet
>> is interfering with Perl core in combination with Tk, not the telnet
>> process
>> itself. One thing to note that this problem (system call not ever
>> returning
>> back to Perl) happens when the button is pressed (or via some other event
>> in
>> Tk).
>
> Maybe it uses threads?
>
> --
> Go to http://MarcDashevsky.com to send me e-mail.
------------------------------
Date: Wed, 3 Jan 2007 00:58:03 GMT
From: David Muir Sharnoff <muir@idiom.com>
Subject: New modules: Plugins, SyslogScan::Daemon::*
Message-Id: <JB9pxB.5HL@zorch.sf-bay.org>
I've just released a few modules:
Plugins
Generic plugins framework. Plugins can have plugins.
Configuration file format undefined.
Plugins::Style1
A simple configuration file format for Plugins.
Plugins::API
An inter-plugin callback framework to dispatch method invocations to
sibling/parent/child plugins.
SyslogScan::Daemon
Watch log files for regular expressions.
SyslogScan::Daemon::SpamDetector
SyslogScan::Daemon::SpamDetector::Postfix
SyslogScan::Daemon::SpamDetector::Sendmail
SyslogScan::Daemon::SpamDetector::SpamSink
SyslogScan::Daemon::SpamDetector::SpamAssassin
SyslogScan::Daemon::SpamDetector::BadAddr
SyslogScan::Daemon::SpamDetector::BadAddr::Sendmail
SyslogScan::Daemon::SpamDetector::BadAddr::Postfix
SyslogScan::Daemon::SpamDetector::Blocklist
Notice which IP addresses are sending spam and
possibly block them.
SyslogScan::Daemon::BlacklistDetector
SyslogScan::Daemon::BlacklistDetector::Postfix.pm
SyslogScan::Daemon::BlacklistDetector::EmailNotify.pm
Notice if you've been blacklisted and send an
email warning.
All of these can be found at http://search.cpan.org/~muir/
-Dave
--
------------------------------
Date: Wed, 03 Jan 2007 00:48:54 +0100
From: oneofthem <mail_nospam@domain.com>
Subject: POE-Component-IRC & whois
Message-Id: <ener1b$p5f$1@sunce.iskon.hr>
Hello,
I am trying to use the irc_whois event to see if a nick is identified to
services.
The manual states:
> irc_whois
> Sent in response to a 'whois' query. ARG0 is a hashref, with the following keys: <cut>
I am trying to do it this way:
sub on_whois{
my ( $kernel, %myhash) = @_[KERNEL, ARG0];
my $nick = $myhash{'nick'};
my $ident = $myhash{'identified'};
print $nick.' - ident state is:'.$ident;
}
But it seems that $nick and $ident are empty.
Can somebody help me do it the right way?
Thanks :)
------------------------------
Date: 2 Jan 2007 16:20:53 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: POE-Component-IRC & whois
Message-Id: <1167783652.999579.76030@i12g2000cwa.googlegroups.com>
oneofthem wrote:
> Hello,
>
> I am trying to use the irc_whois event to see if a nick is identified to
> services.
>
> The manual states:
> > irc_whois
> > Sent in response to a 'whois' query. ARG0 is a hashref, with the following keys: <cut>
note: hashref :)
> I am trying to do it this way:
>
> sub on_whois{
> my ( $kernel, %myhash) = @_[KERNEL, ARG0];
$_[ARG0] is a hash reference, not a hash.
try this instead:
my ($kernel,$hashref) = @_[ KERNEL,ARG0 ];
> my $nick = $myhash{'nick'};
> my $ident = $myhash{'identified'};
now these need to use the reference, not the hash:
my ($nick, $ident) = @{ $hashref }{ qw[nick identified] };
try that.
-jp
------------------------------
Date: Wed, 03 Jan 2007 01:42:21 +0100
From: oneofthem <mail_nospam@domain.com>
Subject: Re: POE-Component-IRC & whois
Message-Id: <eneu5h$td4$1@sunce.iskon.hr>
Thank you very much :)
------------------------------
Date: Wed, 03 Jan 2007 02:04:22 GMT
From: markhobley@hotpop.deletethisbit.com (Mark Hobley)
Subject: printing long decimal numbers
Message-Id: <gkcr64-pp2.ln1@neptune.markhobley.yi.org>
Keywords: print,prinf,decimal,format,display
How do I get Perl to display a long decimal number, without converting to
scientific notation or rounding?
print 6/45*5/44*4/43*3/42*2/41;
4.91095215995953e-06
printf "%lf",6/45*5/44*4/43*3/42*2/41;
0.000005
I would like the following output:
0.00000491095215995953
Thanks in advance.
Mark.
--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE
Telephone: (0121) 247 1596
International: 0044 121 247 1596
Email: markhobley at hotpop dot donottypethisbit com
http://markhobley.yi.org/
------------------------------
Date: 2 Jan 2007 14:48:16 -0800
From: "PerlNovice" <mfarid1@yahoo.com>
Subject: Problematic Perl code
Message-Id: <1167778096.122707.60860@v33g2000cwv.googlegroups.com>
I have the following Perl code:
-------------------------------------------------
#!/usr/bin/perl
use Net::FTP;
$ftp = Net::FTP->new("some.host.name", Debug => 1)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/myfolder")
or die "Cannot change working directory ", $ftp->message;
$ftp->binary;
for( <*.zip> ){
$ftp->get($_,"tmp.$$") or die $!;
$ftp->rename("tmp.$$",$_) or die $!;
$ftp->size($_) == -s $_ or die "$_ sizes don't match";
}
$ftp->quit;
-----------------------------------------------
I need to do the following:
1)I need to copy .zip files from Windows to my Unix folder and name the
.zip files as something else, let's say, .txt. I then need
to rename it back to .zip only when the entire file has been copied.
This is because I'll be unzipping the files later.
There could be multiple .zip files in the Windows folder.
2)Once the file(s) are copied completely, a size comparison needs to be
made between the Windows and Unix sides.
3)If the sizes are the same, then I need to rename the .txt file back
to the .zip file.
I would appreciate any help from anyone.
------------------------------
Date: Tue, 02 Jan 2007 15:24:26 -0600
From: "Mumia W. (on aioe)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Problems with use locale and regexp
Message-Id: <enejgk$6f7$1@aioe.org>
On 01/02/2007 07:35 AM, anno4000@radom.zrz.tu-berlin.de wrote:
> <felix.ostmann@thewar.de> wrote in comp.lang.perl.misc:
>> It is realy strange!
>>
>> first the code:
>> #####################################
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>> use locale; ## WONT WORK
>> use Encode;
>>
>> my $content = Encode::decode("iso-8859-15","[[lmo:Met\xE0j
>> alcal\xEDtt]]\n");
>>
>> $content =~ s!^\[\[[a-z]{2}:.*\]\]$!!gm; ## WONT WORK
>> # $content =~ s!^\[\[[a-z]{2}:.*\]$!!gm; ## WORK
>>
>> print $content;
>> #####################################
>>
>> This bug? shocked me when i was parsing wikipedia-data.
>
> You don't say what "WONT WORK" actually means. Apparently the regex
> match /^\[\[[a-z]{2}:.*\]\]/m never returns with your string and
> locale in effect. That certainly is a bug and if it's still in the
> newest bleadperl (it still is in v5.9.4 DEVEL28658) it ought to be
> reported.
>
> BTW, I assume you are aware that you regex doesn't match (it shouldn't
> loop endlessly, though). The matching regex /^\[\[[a-z]{3}:.*\]\]/m
> doesn't show the problem.
>
> Anno
It looks like a bug in the interpreter to me. Perl locks up when it sees
the substitution operator. I wanted to create a better set of test
cases, but I got distracted by more pressing things:
#!/usr/local/bin/perl5.9.4
use strict;
use warnings;
use locale; ## WONT WORK
use Encode;
printf "Perl %vd\n", $^V;
local $\ = "\n";
my $car = "[[taurus:vehicle\xE0^^]]\n";
print enhex($car);
$car = Encode::decode('iso-8859-15',$car);
print enhex($car);
# $car =~ s/^\[\[[a-z]{2}:.*\]\]$/substituted/gm; # LOCKS UP
# $car =~ s/^\[\[[a-z]{2}:.*\][]]$/substituted/gm; # DOES NOT LOCK UP
# $car =~ s/^\[\[[a-z]{2}:.*\]{2}$/substituted/gm; # LOCKS UP
# $car =~ s/^\[\[[a-z]{6}:.*\]\]$/substituted/gm; # DOES NOT LOCK UP (MATCH)
# $car =~ s/^\[\[[a-z]{5}:.*\]\]$/substituted/gm; # LOCKS UP
# $car =~ s/^\[\[[a-z]{5}:.*\]\Q]\E$/substituted/gm; # LOCKS UP
# $car =~ s/^\[\[[a-z]{5}:[^]]+\]\]$/substituted/gm; # LOCKS UP
# $car =~ s/^..[a-z]{2}:.*\]\]$/substituted/gm; # DOES NOT LOCK UP
$car =~ s/^\[{2}[a-z]{2}:.*\]{2}$/substituted/gm; # LOCKS UP
print $car;
sub enhex {
my $data = $_[0];
$data = unpack 'H*', $data;
$data =~ s/(..)/$1 /g;
$data;
}
__END__
These things seem to be required to evoke the bug:
The locale module must be used. The Encode module must be used to decode
(tested only with iso-8859-15). Two instances of \] or something similar
must appear in the regex. The regex must fail to match.
It's too bad I don't have any more time for this.
--
paduille.4060.mumia.w@earthlink.net
Windows Vista and your freedom in conflict:
http://www.badvista.org/
------------------------------
Date: 2 Jan 2007 15:33:52 -0800
From: "Peter_W_Levine@uhc.com" <Peter_W_Levine@uhc.com>
Subject: ReadKey compile error
Message-Id: <1167780832.044800.276760@s34g2000cwa.googlegroups.com>
Hi,
I am using Perl 5.6.1 (ActivePerl Build 638) on Windows XP.
I tried a test of ReadKey and get the error: 'The application failed
because perl58.dll was not found. Time to upgrade?
Pete
------------------------------
Date: Wed, 3 Jan 2007 12:58:06 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: ReadKey compile error
Message-Id: <459b0f03$0$4753$afc38c87@news.optusnet.com.au>
<Peter_W_Levine@uhc.com> wrote in message
news:1167780832.044800.276760@s34g2000cwa.googlegroups.com...
> Hi,
> I am using Perl 5.6.1 (ActivePerl Build 638) on Windows XP.
>
> I tried a test of ReadKey and get the error: 'The application failed
> because perl58.dll was not found. Time to upgrade?
>
Looks like you've installed a ppm (binary) package that was built fpr perl
5.8 - though I'm a little puzzled as to how that was achieved.
If you're running perl 5.6, you need to install ppm packages that have been
built for perl 5.6.
Cheers,
Rob
------------------------------
Date: 2 Jan 2007 19:11:24 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Regular Expression
Message-Id: <Xns98AC862C3718Fcastleamber@130.133.1.4>
"zowtar" <zowtar@gmail.com> wrote:
> I try use non-greedy quantifiers in other case for filter the url...
> but don't work...
You're using the wrong tool for the job. Have a look at HTML::TreeBuilder.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 2 Jan 2007 16:07:54 -0800
From: rallabs@adelphia.net
Subject: system command won't run with -T option on
Message-Id: <1167782874.754810.48360@s34g2000cwa.googlegroups.com>
Hello: I have a series of cgi scripts which I use to set up an input
file for a compiled C program. I use cookies extensively to keep track
of what parameters the users have chosen or typed into the forms they
see as they negotiate the site. I have been worrying a lot about
security and although I check all user input textboxes when they are
parsed, all the books I read say that using the taint mode is supposed
to be a very good idea. All the scripts I have written have been
successfully 'untainted' except for one that contains a system
command. I used the same procedure to untaint this script as I did
for all my others: I ran it through a search pattern and checked that
it's the proper format. The scripts all work fine when I do this
except the one with the system command. I pasted the script below. It
runs successfully if the -T is removed, but when -T is present I get
the famous 'Internal Server Error'. The error log says: "Insecure
$ENV{PATH} while running with -T switch"
The perl script is:
#!/usr/bin/perl -wT
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard -no_xhtml);
use diagnostics;
my %cookhash=cookie('bigcook');#retrieve cookie 'bigcook'; put into
hash 'cookhash'
my $newID=$cookhash{'newID'};
if ($newID =~ /([\w][\w][\w][\w][\d][\d][\d][\d])/){ #untainting
$newID
my $good=$1;
$newID=$good;
}else { die("Bad data: $newID");
}
system "~/runsgood.exe<hold.$newID >/dev/null"; #execute the compiled
program 'runsgood.exe'
print STDOUT redirect('done.cgi');
I don't understand what to do about the problem if I've untainted the
one piece of external data used.
perlsec says I've got to supply a good path for the script to use, but
I don't know how to do it. I can't figure out how to print out the
environment variable $ENV{PATH} anywhere.
I've been pulling out my hair all day long with this problem, and I'm
about to just give up and turn off the $%*! taint switch.
Mike
------------------------------
Date: 2 Jan 2007 16:13:58 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: system command won't run with -T option on
Message-Id: <1167783238.349075.256260@k21g2000cwa.googlegroups.com>
rall...@adelphia.net wrote:
> All the scripts I have written have been
> successfully 'untainted' except for one that contains a system
> command. I used the same procedure to untaint this script as I did
> for all my others: I ran it through a search pattern and checked that
> it's the proper format. The scripts all work fine when I do this
> except the one with the system command. I pasted the script below. It
> runs successfully if the -T is removed, but when -T is present I get
> the famous 'Internal Server Error'. The error log says: "Insecure
> $ENV{PATH} while running with -T switch"
Right. The error has nothing to do with the command itself. It has to
do with what other commands that command might run.
> perlsec says I've got to supply a good path for the script to use, but
> I don't know how to do it. I can't figure out how to print out the
> environment variable $ENV{PATH} anywhere.
You do not need to print $ENV{PATH} anywhere, but if you wanted to, you
would print it the same way you print anything else. Regardless, you
need to *set* $ENV{PATH}. You need to set the path to be a sequence of
directories from which you want to allow commands to be run. So if
your executable that you're calling via system calls the program
"mycmd.exe", which directories should be searched for mycmd.exe?
Paul Lalli
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 10111
****************************************