[16446] in Perl-Users-Digest
Perl-Users Digest, Issue: 3858 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 31 14:05:36 2000
Date: Mon, 31 Jul 2000 11:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <965066719-v9-i3858@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 31 Jul 2000 Volume: 9 Number: 3858
Today's topics:
Re: Can someone tell me why I can't system() an expect <fnord@mailroom.com>
command-line argument <yidao.cai@uth.tmc.edu>
Re: command-line argument (Marcel Grunauer)
Re: command-line argument <sariq@texas.net>
Re: Convert 1000000 --> 1.000.000 (Abigail)
Re: Convert 1000000 --> 1.000.000 <sariq@texas.net>
Destination Frame from PERL <bg229@scn.org>
Re: Difference between a .cgi file and a .pl file? <abridges@eurobell.co.uk>
Re: Difference between a .cgi file and a .pl file? (Randal L. Schwartz)
Re: Difference between a .cgi file and a .pl file? (Abigail)
Re: Difference between a .cgi file and a .pl file? <flavell@mail.cern.ch>
Re: Difference between a .cgi file and a .pl file? (Randal L. Schwartz)
Re: Hash Question - Please help nobull@mail.com
Re: How do I associate an IP address with an interface? <dominique.plu@ifrance.com>
Re: How do I associate an IP address with an interface? nobull@mail.com
Re: How to print the thousands comma for financial numb (David H. Adler)
Re: How to recognize triplicates (Decklin Foster)
html filter Re: text file to HTML page <yidao.cai@uth.tmc.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 31 Jul 2000 17:29:33 GMT
From: Christopher Robert Woods <fnord@mailroom.com>
Subject: Re: Can someone tell me why I can't system() an expect script?
Message-Id: <8m4d1m$5rt$1@nnrp1.deja.com>
In article <8lsl6r$ucu$1@nnrp1.deja.com>,
Christopher Robert Woods <fnord@mailroom.com> wrote:
> Trying to make an interface to userman on my Solaris boxes, the end
> result being that the user account is created and the password set to
> their username, and then expired. However, in order to set the
> password, I am using an expect script. That doesn't appear to be
> working. userman.pl is the perl script, which just prompts for
> settings. chgpass is the expect script, which takes 2 parameters,
> username and password. They are posted below, if anyone has any
ideas,
> I would be most grateful. Thanks!
<SNIP CODE>
I figured out what I was doing wrong, I was using the exec() function in
some places, and that command executes without waiting for a return from
the program. So, I was trying to change the password of an account that
hadn't been created yet!
I replaced the exec()'s with system()'s and everything worked well.
--
Christopher Robert Woods - MCSE, CCNA
fnord@mailroom.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 31 Jul 2000 11:26:00 -0500
From: Yidao Cai <yidao.cai@uth.tmc.edu>
Subject: command-line argument
Message-Id: <3985A898.287AACE0@uth.tmc.edu>
How can a perl script read command-line arguments, just like a shell
script does with $1, $2 ?
cai
--
email: yidao.cai@uth.tmc.edu
------------------------------
Date: Mon, 31 Jul 2000 16:40:59 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: command-line argument
Message-Id: <slrn8obbbu.ai2.marcel@gandalf.local>
On Mon, 31 Jul 2000 11:26:00 -0500, Yidao Cai <yidao.cai@uth.tmc.edu> wrote:
>How can a perl script read command-line arguments, just like a shell
>script does with $1, $2 ?
perldoc perlvar (check for '@ARGV')
For command-line option processing, see the Getopt:: modules,
e.g. Getopt::Std, Getopt::Long.
--
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Mon, 31 Jul 2000 11:47:23 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: command-line argument
Message-Id: <3985AD9B.340BD044@texas.net>
Yidao Cai wrote:
>
> How can a perl script read command-line arguments, just like a shell
> script does with $1, $2 ?
@ARGV
perldoc perlvar
- Tom
------------------------------
Date: 31 Jul 2000 11:11:53 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Convert 1000000 --> 1.000.000
Message-Id: <slrn8ob5pd.vcg.abigail@alexandra.foad.org>
Tom Briles (sariq@texas.net) wrote on MMDXXVI September MCMXCIII in
<URL:news:39858FD9.CF41BF84@texas.net>:
\\ David Coppit wrote:
\\ >
\\ > # Need to remove any "." added to the end.
\\ > $string =~ s/\.$//g;
\\
\\ tr///d is better there.
Which tr/// expression is equivalent with s/\.$//g (which as a pointless /g)?
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT
------------------------------
Date: Mon, 31 Jul 2000 10:19:56 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Convert 1000000 --> 1.000.000
Message-Id: <3985991C.26B195ED@texas.net>
Abigail wrote:
>
> Tom Briles (sariq@texas.net) wrote on MMDXXVI September MCMXCIII in
> <URL:news:39858FD9.CF41BF84@texas.net>:
> \\ David Coppit wrote:
> \\ >
> \\ > # Need to remove any "." added to the end.
> \\ > $string =~ s/\.$//g;
> \\
> \\ tr///d is better there.
>
> Which tr/// expression is equivalent with s/\.$//g (which as a pointless /g)?
Whoops...there isn't one, of course.
Thanks for the correction.
- Tom
------------------------------
Date: Mon, 31 Jul 2000 13:29:11 -0400
From: "Scott Snella" <bg229@scn.org>
Subject: Destination Frame from PERL
Message-Id: <sobdja6c9ft105@corp.supernews.com>
Hi, I was wondering if someone could help me out with a little problem I am
having. I am wrting a PERL script that calls an HTML file that sets a left
and right frame. That HTML file sends control to two other files that split
the left frame into a top and a bottom and the right frame into 3 smaller
frames. So, when all is said and done, I have five frames on the screen.
Now, the kicker. I need to populate those windows with HTML from a CGI
program. Now, I figured I could set up the frames without a problem and
even name them. Then I can store blank pages in each. At that point I am
looking for a way to display HTML templates in each window that include data
from a mySQL database. I was hoping there was some easy way to tell PERL
what target frame I wanted to display data in.
Right now, I have two semi-solutions. #1, take care of the frame setup in
the perl script rather than with a template, thus allowing me to substitute
the correct parameters in. #2, one suggestion I found on the net was to
write unique temp files and load those. That solution seems a little more
complex that I would like to go.... it will also require cleanup, etc.
Anyone have any ideas on this? I hope there is an easy way!
--
Scott Snella
email: bg229@scn.org
FAX: (743) 448-2438
------------------------------
Date: Mon, 31 Jul 2000 16:22:29 +0100
From: "Andy Bridges" <abridges@eurobell.co.uk>
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <8m453c$19d5$1@slrn.eurobell.net>
the difference is that some servers will only allow a perl script to be
executed as a .cgi file extension.
you will normally find that this happens on older style webservers , most of
the newer webservers ( apache ) accept both .pl and .cgi file extensions.
just to make sure everyone knows this for future reference ;)
"DS" <snakeman@kc.rr.com> wrote in message
news:vjmc5.94$L5.2310@typhoon.kc.rr.com...
> What is the diference betweeen a .pl file and a .cgi file?
> Can I convert a .pl to a .cgi?
>
>
> Thanks
> Dirk
>
>
------------------------------
Date: 31 Jul 2000 08:19:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <m1wvi2wcne.fsf@halfdome.holdit.com>
>>>>> "Andy" == Andy Bridges <abridges@eurobell.co.uk> writes:
Andy> the difference is that some servers will only allow a perl
Andy> script to be executed as a .cgi file extension.
Andy> you will normally find that this happens on older style
Andy> webservers , most of the newer webservers ( apache ) accept both
Andy> .pl and .cgi file extensions.
But even that's still wrong. I don't think I've ever written a CGI
program, in Perl or otherwise, that had to have a required extension.
Since the very first release of Apache (and all of the releases of the
NCSA server from which Apache was derived), a CGI script was
recognized by its leading path, not its extension.
Only in recent versions of Apache have you also been able to add CGI
recognized "anywhere" using an extension, which to me seems to be a
Very Bad Idea from a security perspective, intermingling data and code
much too closely for comfort, not to mention revealing the
implementation language to outsiders making systematic attack easier.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 31 Jul 2000 11:50:12 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <slrn8ob817.vcg.abigail@alexandra.foad.org>
Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDXXVI September
MCMXCIII in <URL:news:m1wvi2wcne.fsf@halfdome.holdit.com>:
$$ >>>>> "Andy" == Andy Bridges <abridges@eurobell.co.uk> writes:
$$
$$ Andy> the difference is that some servers will only allow a perl
$$ Andy> script to be executed as a .cgi file extension.
$$
$$ Andy> you will normally find that this happens on older style
$$ Andy> webservers , most of the newer webservers ( apache ) accept both
$$ Andy> .pl and .cgi file extensions.
$$
$$ But even that's still wrong. I don't think I've ever written a CGI
$$ program, in Perl or otherwise, that had to have a required extension.
$$ Since the very first release of Apache (and all of the releases of the
$$ NCSA server from which Apache was derived), a CGI script was
$$ recognized by its leading path, not its extension.
$$
$$ Only in recent versions of Apache have you also been able to add CGI
$$ recognized "anywhere" using an extension, which to me seems to be a
$$ Very Bad Idea from a security perspective, intermingling data and code
$$ much too closely for comfort, not to mention revealing the
$$ implementation language to outsiders making systematic attack easier.
I've never played with Apache much, but I did with NCSA. And that server
could be configured to allow execution of files as CGI programs based on
file name extension.
I do not share your perceived security aspect. Deciding whether
something is a CGI program or a static document based on file extension
is as arbitrary as the leading path. They both depend on the same path,
whether you look at the end or the beginning isn't significant. And file
extensions are already being used en masse to determine the Content-Type
anyway.
Increasing security by not revealing the implementation language (not that
.cgi reveals anything - or .pl for that matter; I doubt Apache will barf
if you have a Python file (with appropriate shebang line) whose name ends
in .pl) sounds like security through obscurity to me.
IMO, a more reasonable approach to decide whether something is a CGI
program or a static document is to look at the execution bit. If set,
it's a program, else, it's a static document. But apparently, some idiots
decided that the execution bit was a neat trick to decide whether a
document should go through an SSI interpreter.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Mon, 31 Jul 2000 17:49:15 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <Pine.GHP.4.21.0007311727430.9724-100000@hpplus03.cern.ch>
On 31 Jul 2000, Randal L. Schwartz wrote:
> But even that's still wrong. I don't think I've ever written a CGI
> program, in Perl or otherwise, that had to have a required extension.
> Since the very first release of Apache (and all of the releases of the
> NCSA server from which Apache was derived), a CGI script was
> recognized by its leading path, not its extension.
For as long as I can recall, it's been one possible configuration
option.
> Only in recent versions of Apache have you also been able to add CGI
> recognized "anywhere" using an extension,
Excuse me, but, I'd really have to correct you there. My early
encounters with NCSA HTTPD, years ago, involved taking a decision
whether to use ScriptAlias and/or to configure particular filename
extensions for the "magic" content-type for CGI.
And although Apache now prefers the use of AddHandler for the latter
purpose, it still supports the old "magic" content-types for CGI. SSI
and so forth ( application/x-httpd-cgi etc.).
http://www.apache.org/docs/handler.html
> which to me seems to be a
> Very Bad Idea from a security perspective, intermingling data and code
> much too closely for comfort,
There's a lot of truth in what you say, although sometimes there are
reasons for doing it. I'd agree that it calls for a more intensive
security audit.
> not to mention revealing the
> implementation language to outsiders making systematic attack easier.
This isn't always the case.
Consider the "default document", like http://www.foo.bar/baz/
The server can be given a list of file names to try for the default
document: index.html, index.cgi, index.shtm, Welcome.htm
(these are just examples, not a particular recommendation)
and the URL advertised without giving any file name at all.
The site then has the freedom to change from a static file to an
SSI or CGI or back again at any time, without having to tell the world
about it.
If you want to be really secretive, you can set the server to redirect
any explicit requests for these file names, right back to
http://www.foo.bar/baz/
HTH. (Sorry, yes I know it's OT here)
------------------------------
Date: 31 Jul 2000 09:45:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <m1zomyuu3o.fsf@halfdome.holdit.com>
>>>>> "Alan" == Alan J Flavell <flavell@mail.cern.ch> writes:
>> Only in recent versions of Apache have you also been able to add CGI
>> recognized "anywhere" using an extension,
Alan> Excuse me, but, I'd really have to correct you there. My early
Alan> encounters with NCSA HTTPD, years ago, involved taking a decision
Alan> whether to use ScriptAlias and/or to configure particular filename
Alan> extensions for the "magic" content-type for CGI.
Yes, I misremembered (twice in three days :). Happens. :)
Alan> This isn't always the case.
Alan> Consider the "default document", like http://www.foo.bar/baz/
Alan> The server can be given a list of file names to try for the default
Alan> document: index.html, index.cgi, index.shtm, Welcome.htm
Yup. That's OK. But it's scary when I end up seeing a URL in my
location bar of "foo.pl" or "index.py" or "whatever.tcl" though.
Gives away more than it needs to give.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 31 Jul 2000 17:43:30 +0100
From: nobull@mail.com
Subject: Re: Hash Question - Please help
Message-Id: <u9og3efdxp.fsf@wcl-l.bham.ac.uk>
t0873 <t0873@my-deja.com> writes:
> I have a hash which has a filename like
> $VAR1 = {
> 'file' => 'MYFILE' ,
> 'time' => 5,
> 'sent_dir' => '/.../.../',
> }
>
> After the specified time, MYFILE is updated in the sent_dir. Now new
> changes say that MYFILE shouldn't get overwritten, but should have new
> format such as month, day, hour and time. my question is is it possible
> to have a some kind of function , inside the hash which can return the
> new value and ASSIGN to 'file'.
I assume that you mean that you have code that uses $VAR1->{file} and
you are not allowed to change it to $VAR1->file()
If you were prepared to change it the correct approach would be to
replace the simple hash with an object (actually the same hash but
blessed) and use a method to retrieve the filename.
If you really cannot alter the code that's using the hash then you can
make $VAR1->{file} into a tied scalar. See "perldoc perltie".
> so everytime when VAR1 is loaded
> after time , it will have 'file' with MYFILE$mon$mday$hh$mm.
What do you mean by the word 'loaded'? Do you mean that you are
saving this hash with Data::Dumper or suchlike? If you do something
sneaky to $VAR1->{file} then it's probably not going to be dumpable.
On the other hand if you are simply eval-ing the dumped file to read
it in you can clearly embed arbirtary code in the file.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 31 Jul 2000 17:18:01 +0200
From: "Dominique PLU" <dominique.plu@ifrance.com>
Subject: Re: How do I associate an IP address with an interface?
Message-Id: <8m44tr$7tn$1@capella.worldonline.fr>
Hello,
i use a tips for this
look at the script,
open (ipconf, "ipconfig |") ;
@mydata = <ipconf>;
@results = grep(/212.83.15/i,@mydata);
if ($#results >= 0) {
foreach $i (@results) {
# extrait l'adresse IP seulement - extract only the IP adress from the line
string
$adr = substr($i,38,14);
}
}
my isp always give me an adress beginnig with 212.83.15 .....
so i search the string that you find twice, the IP and the defaut gateway,
in NT with dialup they are allways the same,
I use this script to maintain a dynamic link to web host, so to each
reconnection , if the ip adress change, i launch this script to send by
win32::internet FTP function the new adress
This is very simple to do
Hope this will help you
Dominique
<david_henry@my-deja.com> a écrit dans le message :
8m406g$rig$1@nnrp1.deja.com...
> I'm using ActiveState Perl on Win NT.
> I need to know the IP address of a dial-up connection. Using gethost() I
> can get all my current IP addresses. How can I associate each one with a
> partucular device?
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 31 Jul 2000 17:43:44 +0100
From: nobull@mail.com
Subject: Re: How do I associate an IP address with an interface?
Message-Id: <u9n1iyfdxb.fsf@wcl-l.bham.ac.uk>
david_henry@my-deja.com writes:
> I'm using ActiveState Perl on Win NT.
> I need to know the IP address of a dial-up connection.
The normal approach is to open a socket to an address that you know
will be routed over the dial-up connection then look at the address of
the local end of that socket.
> Using gethost() I
> can get all my current IP addresses. How can I associate each one with a
> partucular device?
I suggest installing the SNMP agent on the box in question and using
the SNMP modules.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 31 Jul 2000 16:53:26 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: How to print the thousands comma for financial numbers ( $ 12,8292.75)
Message-Id: <slrn8obbo6.la.dha@panix2.panix.com>
On Mon, 31 Jul 2000 10:06:33 GMT, Gibson <gibson70@libero.it> wrote:
>Eric Bohlman <ebohlman@netcom.com> wrote in message
>8lmbki$i9m$4@slb2.atl.mindspring.net...
>> Louis Banens (louis.banens@xs4all.nl) wrote:
>> : I cannot find out how to print the thousands comma for financial numbers
>( $
>> : 12,8292.75).
>> :
>> : Any ideas ?
>>
>> Use the code shown in perlfaq5.
>
>where is ?
>
>www.perl.com ?
Although it is indeed at www.perl.com, it is also (assuming your perl
installation was done correctly) on your computer, as is all of the
documentatoin for perl.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"You can't give a 4 to truth." - Saul Williams
------------------------------
Date: Mon, 31 Jul 2000 17:24:01 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: How to recognize triplicates
Message-Id: <RCih5.9100$f_5.42965@news1.rdc1.ct.home.com>
I wrote:
> 'not a digit",
It's a good thing I don't type this way when I'm coding... ;-)
--
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
------------------------------
Date: Mon, 31 Jul 2000 11:33:02 -0500
From: Yidao Cai <yidao.cai@uth.tmc.edu>
Subject: html filter Re: text file to HTML page
Message-Id: <3985AA3E.62B08D3E@uth.tmc.edu>
This one will help, I hope.
sub htmlFilter_CreateLink
#
# convert special chars: < > & "
# add <BR>'s after carriage returns
# create web link
#
{
local ($body) = @_;
local (@array) = split("\n", $body);
local ($output);
foreach $i (0 .. $#array) {
$_ = @array[$i];
$_ =~ s/&/&/g;
$_ =~ s/</</g;
$_ =~ s/>/>/g;
$_ =~ s/"/"/g;
if (/http:\/\// || /ftp:\/\//) {
my (@subarray) = split(" ", $_);
foreach $j (0 .. $#subarray) {
$_ = @subarray[$j];
# link fails if "http://...html."
if (/http:\/\// || /ftp:\/\//) {
$output .= "<a href=\"$_\">$_</a> ";
}
else {
$output .= $_ . " ";
}
}
$output .= "\n<br>";
}
else {
$output .= $_ . "\n<br>";
}
}
return $output;
}
email: yidao.cai@uth.tmc.edu
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3858
**************************************