[8656] in Perl-Users-Digest
Perl-Users Digest, Issue: 2273 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 8 06:07:42 1998
Date: Wed, 8 Apr 98 03:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 8 Apr 1998 Volume: 8 Number: 2273
Today's topics:
Re: $value=~ s/\"/\*/gi; # translate " to * doesn't <cnwetzel@linguistik.uni-erlangen.de>
Re: -comparing the values of 2 arrays- <rjk@coos.dartmouth.edu>
Re: Clever algorithms for generating robots.txt from li <rjk@coos.dartmouth.edu>
Re: fgrep'ing around . . . . (Lars Gregersen)
Re: fork() and exec() example needed please... <cnwetzel@linguistik.uni-erlangen.de>
HELP ME PLEASE <twrq@usa.net>
How to get a Perl CGI to perform a POST action <eviljim@megsinet.net>
Re: How to get a Perl CGI to perform a POST action <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: How to get a Perl CGI to perform a POST action <justin@nectar.com.au>
NT: pass STDOUT to a child program? (Michael)
Re: Open Read File of size GT 2 Gig <cnwetzel@linguistik.uni-erlangen.de>
Re: Parsing the command line <rpsavage@ozemail.com.au>
Re: Perl in Visual Studio <tony@cyberscape.net>
Re: Perl on ancient iron (Martien Verbruggen)
perl win 32 : asterisk on command line <WS010@dvvlap.be>
Re: RMS should be invited to O'Reilly's "Free Software subhas@delete.pobox.com
Re: RMS should be invited to O'Reilly's "Free Software (Ilya Zakharevich)
Re: RMS should be invited to O'Reilly's "Free Software (Michael Funk)
Re: RMS should be invited to O'Reilly's "Free Software (Ilya Zakharevich)
Server Errors - unreliable? (remove)@dial.pipex.com (Rod Borland)
Re: Server Errors - unreliable? <grinch@whoville.com>
Re: setUID script <eugene@vertical.net>
Re: setUID script (Bart Lateur)
Re: Simple Unix Question, ( Simple for you maybe ) (Tad McClellan)
Re: Socket connection problems (new) <qdtcall@esb.ericsson.se>
Re: Variable interpolation problems <jdf@pobox.com>
Re: Variable interpolation problems (Andre L.)
Re: Web spider/crawler script (Andy Wardley)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 08 Apr 1998 11:33:12 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: $value=~ s/\"/\*/gi; # translate " to * doesn't work either
Message-Id: <352B4458.7210@linguistik.uni-erlangen.de>
Brendan Murphy wrote:
> I am trying to replace " by a * so that it would not mess up a form whe=
re I
> use the data ..... for some reason I cannot replace it.... I have tried=
> everything except of course the right thing...
> =
> $value=3D~ s/"/\*/gi; # translate " to * but doens'=
t work
> $value=3D~ s/\"/\*/gi; # translate " to * but doens=
't work
Sorry, but both work fine for me, and I can't see the
problem. The error must be in setting $value before,
or in how $value is used after the replacement.
By the way: With non-alphabetical characters like
" and * you don't need the /i modifier; it slows
down the performance, so try to avoid it if possible.
Christian
-- =
Eine Garantiepflicht wird nicht ausgel=F6st durch
geringf=FCgige Abweichungen von der Soll-Beschaffenheit,
die f=FCr Wert und Gebrauchstauglichkeit unerheblich sind.
------------------------------
Date: Tue, 07 Apr 1998 23:32:12 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: -comparing the values of 2 arrays-
Message-Id: <352AEFBE.EA83C9BD@coos.dartmouth.edu>
James Ludlow wrote:
>
> Ronald J Kimball wrote:
> >
> > @_{@array1, @array2} = 0;
> > @newarray = keys sort %_;
> ^^^^^^^^^
> @newarray = sort keys %_; # obviously just a typo.
Thanks for pointing that out. I originally wrote the code without 'sort',
then when I added it later I put it in the wrong place.
> Okay, let me see if I understand what's going on here. I'd appreciate
> some input if I get this screwed up.
>
> @_ threw me at first, because I'd only ever used it in a subroutine.
> But, apparently "_" is just the name of the hash that is being created.
> It could have been written as @a or @whatever.
Yup, _ is the name of a hash. @_{} is a hash slice. (As opposed to @_[],
which is an array slice - gotta watch those subscript characters.)
> Inside the {} the values of @array1 and @array2 act as though they were
> written like ("12 ","13 ","14 ",15 ","14 ","15 ","16 ","17 ").
Right.
> So then for each value in the list inside the {}, the hash, %_, gets the
> next value from the list on the right side of the equals sign. In this
> case the list consists of one number, "0", so only the first key will
> have a value, and the rest will be undef. It could have been written
> @_{@array1,@array2} = (0,,,,,,,); (Not that you would want to do it that
> way of course).
Hmm... Oops, that was a mistake on my part. I was expecting all of the keys
to get the value. I wonder if there is a simple way to initialize a hash
slice to a specific value with an unknown number of keys. I guess
@_{@array1,@array2} = (0) x (@array1 + @array2) would work, but it creates
extra values that just get thrown away.
In my code, @_{@array1,@array2} = () would have made more sense, I think.
By the way, it's worth considering the result of the following line:
@hash{qw(a b c b d)} = (1..5);
> But, these undef values don't matter, because all we're interested in is
> the keys.
Which is fortunate, because my code wouldn't have worked otherwise.
*sheepish grin*
> Then the "keys" function simply gives us a list of the keys, which just
> happens to be a list of unique values from the arrays.
Exactly. Anytime your question involves the word "unique", there's a good
chance that a hash will do what you want.
> Wow. I realize that the code itself is straight out of the FAQ, but
> until now I never bothered to try to figure out why it worked. I never
> thought about using a hash with the @ sign. I'd only used %hash, or the
> $hash{} in a loop. It's yet another instance where Perl just continues
> to amaze me.
Except the FAQ doesn't have the silly errors, I'm sure. :-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 08 Apr 1998 00:50:56 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: Ernest Mueller <ernestm@towery.com>
Subject: Re: Clever algorithms for generating robots.txt from list of allowed files?
Message-Id: <352B0235.ECF527D5@coos.dartmouth.edu>
[posted and mailed]
Ernest Mueller wrote:
>
> This works fine, except it makes a bigger robots.txt than it needs to (and by
> that I mean 600K) - it doesn't understand that if there are no files to be
> included under /foo/bar than it should just say Disallow: /foo/bar and not
> recursively list every subdirectory and file in /foo/bar.
Okay, you've got two lists of files. One is a list of files to include, and
the other is the list of files in the current directory. What you need to do
is compare the two lists. If any of the files in list A are present in list
B, then you need to remove them from list B and disallow all the remaining
files. If none of the files in list A are present in list B, then you ignore
all of list B and just disallow the current directory. You will still need to
take into account all the subdirectories.
A depth-first traversal could be useful here, allowing you to 'collapse'
subdirectories when they don't contain any files to be included.
Does that help?
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 08 Apr 1998 07:33:44 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: fgrep'ing around . . . .
Message-Id: <352b26e6.87781461@130.228.3.8>
On Tue, 7 Apr 1998 14:07:37 GMT, mdperry@gpu.utcc (Marc Perry) wrote:
> I have been using the unix csh fgrep command to find simple short
>string patterns in files. Life is much easier for me if I use the -f
>flag to specify the filename containing the files I want to search for.
>It turns out that fgrep has an upper limit (between 360-478 patterns--I
>am not precisely sure where the boundary is) that I would like to get around.
>
>I imagine a perl script exists that has the same functionality as
>fgrep (but without the limitations)--but I have yet to learn perl
>programming skills. My main foray besides purchasing several books
>has been to use a program in the camel book named wordcount. Using
>a web browser I found code for cgrep, and tgrep. Could someone please
>point me to a source for fgrep?
findgrep will do this.
You can get it at:
http://www.gbar.dtu.dk/~matlg/findgrep/
I don't know the limit on how many patterns you can enter and there
shouldn't be any, but let me know if you find a limit.
Note that a Perl implementation will have to be slower than a real
(f)grep and that there are probably smarter ways of doing what you're
doing. If the patterns are similiar you can combine patterns. If you
are doing this kind of searches a lot you can really benefit from
having an index and search the index instead of the files. I'm
currently working on such an indexing programme. It is of course made
in Perl. Let me know if you would like to beta test it.
Lars
Lars Gregersen, M.Sc., Chem. Engng.
Technical University of Denmark
Department of Chemical Engineering
E-mail : lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/
------------------------------
Date: Wed, 08 Apr 1998 11:07:55 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: fork() and exec() example needed please...
Message-Id: <352B3E6B.20BA@linguistik.uni-erlangen.de>
Michael Shavel:
> Ps. this is the code I am starting with, but all it seems to do is exec=
ute the
> sqr statment twice without returning the PID into $pid.
> =
> $c=3D"sqr trsdmp.sqt test/test -RT -F/export/transfer/trsdmp.lis 03/03/=
1998";
> =
> $pid =3D fork();
> print "PID num id $pid \n";
> exec($c);
After a fork, you get 2 identical processes whose next
program step is the one following fork(). The only
difference is that the $pid of the child process is
zero, and the $pid of the parent process is the pid
of the created child process. In your example, you
execute exec($c) without caring if you are parent
or child, so it is executed by both. If you want only
the child to exec(), you have to do it like this:
$c=3D"sqr trsdmp.sqt test/test -RT -F/export/transfer/trsdmp.lis 03/03/19=
98";
$pid =3D fork();
if ($pid) =
{ # Here comes the parent
# do something interesting
}
else =
{ # Here comes the kid
exec($c);
exit; # don't forget to exit the child process
}
# if you exit the child, only the parent continues here
But you have to be careful to avoid zombie child
processes, so please take a look at the perllipc =
manpage and the documentation for fork and wait/waitpid.
Further information about how to use fork you can
find in the book "Advanced Programming in the UNIX
Environment" by W. Richard Stevens which describes
everything in C.
Christian
-- =
Bei Augenber=FChrung mit viel Wasser nachsp=FClen.
------------------------------
Date: Tue, 7 Apr 1998 23:47:48 -0500
From: "Twister" <twrq@usa.net>
Subject: HELP ME PLEASE
Message-Id: <6gevb2$ppp$1@ionews.ionet.net>
Hi!
I need some help. How can I do this: when somebody put a the right
password in a blank, and click "Submit" he or she will receive a file. Thank
you very much.
------------------------------
Date: Tue, 07 Apr 1998 22:31:42 -0500
From: Jim Reardon <eviljim@megsinet.net>
Subject: How to get a Perl CGI to perform a POST action
Message-Id: <352AEF9E.1E54DC70@megsinet.net>
Hello, I'm a fairly new Perl programmer and have read through a couple
of books, but really couldn't find any good information on how to make a
Perl program simulate a POST action (most likely to another Perl
program).
I also tried a CPAN search but couldn't find anything on the subject (I
could have bungled up the search, though).
If anyone could help me out, give me some sample code, or point me to a
good URL about this, I'd greatly appreciate it. Thanks!
------------------------------
Date: 08 Apr 1998 09:20:55 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: How to get a Perl CGI to perform a POST action
Message-Id: <7x90pgrd7s.fsf@beavis.vcpc.univie.ac.at>
Re: How to get a Perl CGI to perform a POST action, Jim
<eviljim@megsinet.net> said:
Jim> good information on how to make a Perl program simulate
Jim> a POST action (most likely to another Perl program).
perldoc LWP
and more specifically...
perldoc LWP::UserAgent
perldoc HTTP::Request
(and related modules).
Jim> I also tried a CPAN search but couldn't find anything
Jim> on the subject (I could have bungled up the search,
Jim> though).
Look for the WWW modules.
hth
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.
------------------------------
Date: Wed, 08 Apr 1998 17:27:34 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: How to get a Perl CGI to perform a POST action
Message-Id: <352B26E6.B4350A50@nectar.com.au>
Jim Reardon wrote:
> Hello, I'm a fairly new Perl programmer and have read through a couple
> of books, but really couldn't find any good information on how to make a
> Perl program simulate a POST action (most likely to another Perl
> program).
>
> I also tried a CPAN search but couldn't find anything on the subject (I
> could have bungled up the search, though).
>
> If anyone could help me out, give me some sample code, or point me to a
> good URL about this, I'd greatly appreciate it. Thanks!
try cgi-lint. I thinks its on cpan
------------------------------
Date: 8 Apr 1998 04:39:56 GMT
From: "Victoria and Hsiwei Yu (Michael)" <vhyu@pop.erols.com>
Subject: NT: pass STDOUT to a child program?
Message-Id: <01bd62a3$acf87fc0$8092accf@vhyu.erols.com>
Hi,
Need to write CGI Perl calling another program, say SAS, on NT, but how can
I let the child program know the STDOUT?
On UNIX, I used
system( .. );
then the child program automatically inherits STDOUT from parent. So the
child program writes to web page OK just as the parent Perl can.
What's the corresponding rule for NT? How to refer to that parent's STDOUT?
Or
print "..."; # that place the parent Perl knows, but the child program
doesn't know???
Thanks in advance,
Michael
------------------------------
Date: Wed, 08 Apr 1998 11:13:31 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: Open Read File of size GT 2 Gig
Message-Id: <352B3FBA.28F3@linguistik.uni-erlangen.de>
Ken Kohl:
> My call to open is failing in attempting to open a file of greater than
> 2 Gig. Any way around this other than using split?
Is the call for open failing, or do you try to read
everything at once in an array? Please provide us an
example of your code and be more specific. Normally,
if you do
open(DATA,"somefile") || die "couldn't open: $!";
while (<DATA>) {
# ...
}
close (DATA);
there is no memory problem, as long as the parts of
your input file (defined by the separator $/) are not
too big. I did even process files of 50MB and more
without problems.
Christian
--
Aufstellen auf rutschfester Unterlage wird empfohlen.
------------------------------
Date: Wed, 08 Apr 1998 13:19:15 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Parsing the command line
Message-Id: <352ADEA3.3DAD@ozemail.com.au>
Andrew F. Lee wrote:
[snip]
> e.g. foo.pl -h gives:
>
> usage: foo.pl [-aBcdehl] input-file [[-o output-file | command]]
>
> User gives me "foo.pl -el bar.txt -o bar.html" and I go do something
> clever.
[snip]
If you want documentation to appear when you use -help, say, them do I have amodule for you!
On my web site you'll find Getopt::Simple, a wrapper around Getopt::Long, which allows you
to supply help text, default values (eg via the environment), etc.
--
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage
------------------------------
Date: Wed, 8 Apr 1998 10:48:09 +0100
From: "Tony Kenny" <tony@cyberscape.net>
Subject: Re: Perl in Visual Studio
Message-Id: <6gfh54$seo$1@svr-c-01.core.theplanet.net>
I use a program called ED for Windows which has quite a few useful features.
Take a look at http://www.getsoft.com/
~Tony
ADR Webmaster wrote in message <352ABD89.51926758@mvrs.com>...
>Kevin B Cohen wrote:
>
>> if you find one, please let the rest of us know... have you tried
>> creating perl scripts with the extension .cpp?
>
>Yeah, and the results are what you'd expect...lame.
>
>Maybe I can cook something up w/ VBscript. Thanks for the idea, though.
>
> -/matt/-
>
>p.s. - I figure at some point Perl will end up in the Visual Studio.
>Maybe I'll just have to wait for that. (I can just see the MS ads now:
>"New! It's Visual Perl ...embraced and extended for Windows". Yeah.)
------------------------------
Date: 8 Apr 1998 03:38:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl on ancient iron
Message-Id: <6gerf4$8lp$1@comdyn.comdyn.com.au>
[You should instruct your news reader to wrap lines at fewer than 80
characters. Your post is very hard to read otherwise.]
In article <352A4318.B308958C@drmail.dr.lucent.com>,
"131J50000-HoltryF(DR3165)260" <fholtry@drmail.dr.lucent.com> writes:
[REFORMATTED]
> What that means is that I can't do the Configure, but I can submit
> the makes. I've tried attacking it iteratively, ie. make a guess
> about config.sh parameters, submit, fix problems, try again. While
> this might eventually succeed, 'eventually' is beginning to look
> like a very long time indeed.
You should read through the file INSTALL that comes with the
distribution. It mentions that you can run Configure in 'batch' mode,
that is non-interactive:
sh Configure -des
After that you can run a make, or run configure again with other
options. They're described in INSTALL and in the script itself. (Try
./configure --help)
> So: does anyone have a config.sh that is known to have worked on
> such a machine that they can share with me? I also have the same
> problem with an HP-UX A.09.04 machine.
it will be created by sh Configure -des, most likely. Otherwise you
should be able to specify the os as an option (uts is the one you
probably want)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: 8 Apr 1998 09:32:04 GMT
From: "WS010" <WS010@dvvlap.be>
Subject: perl win 32 : asterisk on command line
Message-Id: <01bd62d2$1fa47e10$8c7479c1@dvvbeint0ws010>
context: perl for win 32 port
problem: perl -w somescript.pl -l thisarg -p * -u thatarg
perl seems to expand the '*' command line argument to the current directory
contents.
in other words: upon invocation the following expression holds (on my
systems) :
@ARGV == ('-l','thisarg','-p','firstfile','secondfile' ...,'-u','thatarg')
where firstfile and secondfile ... are present in the current directory.
question: To my knowledge no such feature is documented (Yes, I checked the
canonical documentation resources before posting this). Any rational
explanation ?
Many thanks from: Jos Snellings, Jos.Snellings@1cd4u.com
------------------------------
Date: 07 Apr 1998 23:30:21 EDT
From: subhas@delete.pobox.com
To: Andy Tai <atai@zizkov.ucsd.edu>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6ger0d$p4u@examiner.concentric.net>
[Posted and mailed]
In article <edzphyf52w.fsf@zizkov.ucsd.edu>,
Andy Tai <atai@zizkov.ucsd.edu> writes:
> Don Bashford <bashford@gage.scripps.edu> writes:
>
>> Andy Tai <atai@tyrell.ucsd.edu> writes:
>>
>> > Mr. Tim O'Reilly will host a "Freeware Summit"
>>
>> > but noteably
>> > absent from the list is Richard Stallman....
>> >
>> > I think we should write to Mr. O'Reilly (tim@oreilly.com) asking him
>> > to reconsider....
>>
>> Not so fast! It may be that RMS was invited but turned it down.
>> Do you really know? ...
>
> Mr. Tim O'Reilly said that RMS was not invited. I consider this is
> unfair to GNU.
Hmm. If RMS does not qualify, then maybe Bill Gates is invited
(because IE is a freeware).
------------------------------
Date: 8 Apr 1998 04:18:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6getre$l12$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to
<subhas@delete.pobox.com>],
who wrote in article <6ger0d$p4u@examiner.concentric.net>:
> > Mr. Tim O'Reilly said that RMS was not invited. I consider this is
> > unfair to GNU.
>
> Hmm. If RMS does not qualify, then maybe Bill Gates is invited
> (because IE is a freeware).
No it is not. You are mixing "free" and "free".
Hope this helps,
Ilya
------------------------------
Date: 8 Apr 1998 05:45:30 GMT
From: mwfunk@uncc.campus.mci.net (Michael Funk)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <slrn6im3tb.v46.mwfunk@localhost.domain>
On 8 Apr 1998 04:18:54 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to
><subhas@delete.pobox.com>],
>who wrote in article <6ger0d$p4u@examiner.concentric.net>:
>> > Mr. Tim O'Reilly said that RMS was not invited. I consider this is
>> > unfair to GNU.
>>
>> Hmm. If RMS does not qualify, then maybe Bill Gates is invited
>> (because IE is a freeware).
>
>No it is not. You are mixing "free" and "free".
And doing so quite freely. :)
I think RMS is quite capable of defending himself here. It's
debatable (IMHO) whether he is helping or hindering free software
at this point.
Mike
------------------------------
Date: 8 Apr 1998 07:27:23 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6gf8sr$25f$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Michael Funk
<mwfunk@uncc.campus.mci.net>],
who wrote in article <slrn6im3tb.v46.mwfunk@localhost.domain>:
> >> (because IE is a freeware).
> >
> >No it is not. You are mixing "free" and "free".
>
> And doing so quite freely. :)
>
> I think RMS is quite capable of defending himself here. It's
> debatable (IMHO) whether he is helping or hindering free software
> at this point.
Of course he is helping! It is very helpful to have an example of
what you like, and an example of what you do not. :-(
Ilya
------------------------------
Date: Wed, 08 Apr 1998 06:44:42 GMT
From: rodb(remove)@dial.pipex.com (Rod Borland)
Subject: Server Errors - unreliable?
Message-Id: <352b18c7.3378699@news.saix.net>
why do you so many times get error messages returned when calling a
perl script even though the script has executed perfectly. Posting
messages to a message board or subscribing to a mail list the browser
or server will pop back an error message even though the action has
been completed.
You press subscribe on a form and you check the subscription list via
FTP and it has worked and about 5 minutes later you get an error
message in the browser - is this a cgi feature?
Rod Borland
rodb(remove)@dial.pipex.com
http://www.ten.org/
http://www.wildnetafrica.com/
------------------------------
Date: Wed, 8 Apr 1998 05:20:20 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Server Errors - unreliable?
Message-Id: <6gfenn$h2m@fridge.shore.net>
rodb (remove) (Rod Borland) <@dial.pipex.com> wrote in message
<352b18c7.3378699@news.saix.net>...
>why do you so many times get error messages returned when calling a
>perl script even though the script has executed perfectly.
Because it hasn't executed perfectly? :-)
Seriously though...
The biggest cause of this in my experience has been when a script takes a
relatively long time to complete, causing the browser to time out.
-grinch
--
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me
Sherm Pendley
grinch@whoville.com
http://www.whoville.com
------------------------------
Date: Tue, 07 Apr 1998 22:06:21 -0500
From: Eugene Sotirescu <eugene@vertical.net>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: setUID script
Message-Id: <352AE9AA.EC03D74A@vertical.net>
Here's a bare bones example. This script runs suid and is called from a
simple form that has one input field. The unser input from that text field
is retrieved and written to a file.
#send die messages to the browser
use CGI::Carp 'fatalsToBrowser';
##set PATH explicitely to please Perl (use full paths)
$ENV{'PATH'} = '' if $ENV{'PATH'} ne '';
##autoflush buffer
$| = 1;
##flock operation param
$LOCK_EX = 2;
print "Content-type: text/html\n\n";
&ReadParse(*form_data);
$text = $form_data{'text'};
print "User input is: $text\n"; #just to check what's going on
##untaint user input to please Perl
##any pattern match will untaint the variable, but it is hoped
##the pattern match is going to be something intelligent that would
##filter out dangerous characters
$text = $1 if ( $text =~ /^([\w.]+)$/ );
print "After untainting, user input is: $text\n"; #just to check what's
going on
##this file has to be writable by the effective id of the script
$file = "/usr/ns-home/wisdom/onlines/poweronline/write_test";
open FH, ">$file" or die ("Can't open $file");
flock ( FH, $LOCK_EX );
print FH $text;
close FH;
Eugene
Bart Lateur wrote:
> I've read PERLSEC very closely, digested it for over a week, and found
> some info in the Camel Book (and I may press "some"), but the finer
> details of setUID scripts still escape me.
>
> Let me stress that the purpose is for use in CGI, so security is very
> important.
>
> As far as I understand: you can set the setUID bit for a script, and
> then it will be run under the owner of the script's UID. The two special
> variables contain UID's:
>
> $< who launched the script ("nobody")
> $> who owns the script (site owner)
>
> But what am I to do with it? I'm not even sure what the examples in the
> Camel in PERLSEC are intended for. Clarification of these examples would
> be very welcome.
>
> This particular application is for updating a data file, based on user
> supplied info (as I said, in CGI). I don't want this particular data
> file to be publicly writable, so I think I'll have to do the actual
> updating using a setUID script.
>
> What I reconsider doing is:
>
> * Place a normal CGI script in my cgi-bin directory
> * Place a setUID script in a directory that cannot possibly be accessed
> from the WWW
> * Launch this setUID script from within the CGI script.
> * Use a pipe to pass the data to write, through to the setUID script.
>
> Is this a decent approach? Are there particular security risks I have
> overlooked?
>
> And what code structure would you propose for my Perl scripts?
>
> Bart.
------------------------------
Date: Wed, 08 Apr 1998 08:14:13 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: setUID script
Message-Id: <352c2d8f.6875346@news.tornado.be>
Thanks to everybody who replied. What you wrote confirmed what I thought
I knew. setUID scripts do work on my server, BTW. I was just worried
about security.
Tom Phoenix wrote:
>Shouldn't need to do all that. Your set-id script may do the updating
>itself. Just ensure that it never trusts any data that your user supplied.
>Double-check everything the user sent. Hope this helps!
Are you saying that I'm too paranoid? That I can just safely make my
CGI-script setUID?
I was thinking about "security through obscurity". A coworker of mine
claims that at one time he got a listing of a script instead of it
executing. File modes were ok at the time, so it must have been a
temporary server error. It never happened to me.
It was a different server anyway. But, in case something goes wrong, I
wouldn't want to give hackers too many clues.
>> But what am I to do with it?
>
>Whatever you want. :-)
Ah. I ment "what am I to do with $< and $>". For instance, what is this
for? (in a child fork)
$< = $>;
Is this for the child process to abandon it's privileges, and continue
running as "nobody"? And what could this possibly be used for?
($<,$>) = ($>,$<); #swap real and effective UID
Bart.
------------------------------
Date: Tue, 7 Apr 1998 22:38:28 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Simple Unix Question, ( Simple for you maybe )
Message-Id: <kfreg6.gl.ln@localhost>
Namsuk Kim (a-namsuk@microsoft.com) wrote:
: Try @variable = `ls -l`
: I think this is what you meant.
Why do you think that?
: Tad McClellan wrote in message ...
: >UNIXstuff (unixstuff@aol.com) wrote:
: >
: >: From with a perl script.
: >: I want to run the UNIX command ls -l
: >: and have the info/string stored in a variable.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
: > $my_variable = `ls -l`;
That looks like a string stored in a variable to me.
Try:
--------------------------------------
#!/usr/bin/perl -w
@variable = `ls -l`; # each line gets its own array element
print '==>', @variable, "<==\n\n\n";
$my_variable = `ls -l`; # all mashed together into a single string
print "==>$my_variable<==\n";
--------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 08 Apr 1998 08:58:44 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Socket connection problems (new)
Message-Id: <iszphw240r.fsf@godzilla.kiere.ericsson.se>
Web-Hotel Danmark <support@webhot.dk> writes:
> I've still got problems getting a file by HTTP using a socket
> connection, the only result I get, is the main-page from the
> HTTP-server running on the same machine I execute the script on!!
If you really, really want to re-invent wheels, go get a good book on
Unix socket programming and the HTTP RFCs.
Or, if you just want to solve a problem, you *could* take advantage of
the fact that you're not the first one ever to want to fetch stuff via
HTTP, install the LWP package from CPAN and do this:
#!/usr/bin/perl
use LWP::Simple;
$a = get("http://www.example.com/whatever/");
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 08 Apr 1998 00:11:14 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Variable interpolation problems
Message-Id: <vhsk3nkd.fsf@mailhost.panix.com>
Tom Phoenix <rootbeer@teleport.com> writes:
> Eval can be evil.
Hmm.
#!/usr/bin/perl -w
evil { die, die, die ! }
warn $@;
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Tue, 07 Apr 1998 23:16:02 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Variable interpolation problems
Message-Id: <alecler-0704982316020001@dialup-559.hip.cam.org>
*** PLEASE DISREGARD MY REPLY ***
A case of not reading with enough attention. Sorry.
A.L.
In article <alecler-0704981541190001@dialup-639.hip.cam.org>,
alecler@cam.org (Andre L.) wrote:
> In article
> <Pine.A41.3.96.980407194338.38434A-100000@ilx374.iil.intel.com>, Stas
> Bekman <sbekman@ilx374.iil.intel.com> wrote:
>
> > Hi,
> >
> > I'm trying to make the following. But in vain...
> >
> > $abc = 345;
> > $a = 'This is $abc';
> > $b = eval {$a};
> > print $b,"\n";
> >
> > I want to get :
> > This is 345
> > but I get
> > This is $abc
>
> Ah, come on. This is *so* basic.
>
> Write:
> $a = "This is $abc";
> print $a;
>
> The string needs to be double-quoted for the variable inside to be
interpolated.
>
> RTM to learn the difference between single and double quotes.
>
> A.L.
------------------------------
Date: Wed, 8 Apr 1998 07:16:02 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: Web spider/crawler script
Message-Id: <Er32uq.1LB@cre.canon.co.uk>
Peter <delphiask@sale-net.com.au> wrote:
>Hi all. I am trying to find a spider or crawler type script I can use
>on a linux box.
There's a perl module out there that already does this for you:
WWW::Robot
Have a look on CPAN in
http://www.perl.com/CPAN/modules/by-module/WWW/
There are plenty of other modules there that you may also find useful
for WWW programming.
A
--
Andy Wardley <abw@kfs.org> http://www.kfs.org/~abw
Signature lost in transit. We apologise for any inconvenience caused.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2273
**************************************