[9556] in Perl-Users-Digest
Perl-Users Digest, Issue: 3151 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 14 11:28:02 1998
Date: Tue, 14 Jul 98 06:05:20 -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 Tue, 14 Jul 1998 Volume: 8 Number: 3151
Today's topics:
Rusty pipes (Miguel Cruz)
Sendmail ? <info@shopsmart.com.au>
Re: Sendmail ? <quednauf@nortel.co.uk>
Re: Sendmail ? (David A. Black)
Simple problem with perl script. <webmaster@acidhouse.com>
Re: Simple problem with perl script. <quednauf@nortel.co.uk>
Re: Simple problem with perl script. <qdtcall@esb.ericsson.se>
Re: Urgent!! Need Programmer for perm in Malibu, Ca <quednauf@nortel.co.uk>
w3c/CERN directory protection <i.m.hay@man0524.wins.icl.co.uk>
Re: w3c/CERN directory protection <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: WebBots <steve.mortimer@eds.com>
Re: What's the substitute for #! /usr/bin/perl in Win32 <jwb79@mail.idt.net>
Re: Why is Dave operating here? (was Re: REPOST: Re: ) (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jul 1998 09:31:46 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Rusty pipes
Message-Id: <6of8i2$bqn$1@news.ycc.yale.edu>
I guess it's easiest to start with this foreshortened snippet:
128 sub do_command {
129 local $cmd = pop (@_);
130 open(PIPE, $cmd." 2>&1 |");
131 while (<PIPE>) {
132 print;
133 }
134 close PIPE;
135 }
I know that looks remarkably dangerous, but let's just assume for now that
I've checked the input or only I will be able to execute the code or
something.
Anyway, what used to happen was that the command in the argument to the
subroutine would be executed, and stdout/stderr would be printed, and Perl
would happily continue its work.
Now I've moved this to an object, and it works almost the same - EXCEPT that
after the command terminates (and, in this case, produces 4 lines of
output), I get these messages:
Use of uninitialized value at /home/mnc/tmm//NS_System.pm line 132, <PIPE>
chunk 4.
Use of uninitialized value at /home/mnc/tmm//NS_System.pm line 132, <PIPE>
chunk 4.
Unable to create sub named "" at /home/mnc/tmm//NS_System.pm line 132,
<PIPE> chunk 4.
...and then the Perl program is dead. I'm particularly curious about the
last of the three messages.
I don't understand what's changed to make 'while' seemingly unable to detect
the closure of the pipe from $cmd.
In order to demonstrate my ignorance, I tried changing the print variously
to:
print if $_;
print unless eof();
print if -t PIPE;
...but none of these helped.
I would be very grateful for any tutelage or tips; I couldn't find anything
quite like this in older postings here or in the web sites that Altavista
turned up.
miguel
------------------------------
Date: Tue, 14 Jul 1998 19:55:17 +1000
From: "Sean" <info@shopsmart.com.au>
Subject: Sendmail ?
Message-Id: <6ofadg$488$1@toto.tig.com.au>
Hello,
I am new to perl and i am trying to get this perl script working to send
mail, but i keep encountering this error when i click send.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator,and inform them of the time the
error occurred, and anything you might have done that may have caused the
error.
I have included a copy of the script below, if someone could give me a clue
as to what i am doing wrong that would be much apreciated.
Thank you in advance for your answer
Sean
#!/usr/tools/bin/perl -*-perl-*-
# Print this out no matter what
print "Content-type: text/html\n\n";
# flush stdout buffer
$| = 1;
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
# How many bytes are we supposed to receive?
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$contents{$name} = $value;
}
}
chop($date = `date`);
###############################################
# CGI Output: As HTML and as an email message
###############################################
# Create an HTML document on the fly. Yee-haw!
print <<"HTML";
<HTML>
<HEAD><TITLE>A.S.S. Travel Form Entries</TITLE></HEAD>
<BODY>
<H1>Travel Request from $contents{'name'}</H1>
<P><HR><P>
<I>$date</I>
<UL>
<LI> Name = $contents{'name'}
<LI> Email = $contents{'email'}
<LI> Departure date = $contents{'ddate'}
<LI> Departure time range = $contents{'dtime'}
<LI> Return date = $contents{'rdate'}
<LI> Return time range = $contents{'rtime'}
HTML
# check the airline section of the form data
if($contents{'airline-ind'} eq 'indiffernt') { ; }
else {
print "<LI> Airline (first choice) = $contents{'airline1'}\n";
if($contents{'airline2'} ne '') {
print "<LI> Airline (second choice) = $contents{'airline2'}\n";
}
}
print <<"HTML";
<LI> Destination City = $contents{'city'}
<LI> Destination State = $contents{'state'}
<LI> Smoking preference = $contents{'smoking'}
<LI> Reason for trip = $contents{'reasons'}
HTML
if($contents{'reasons'} ne '') {
print "<LI> Reasons = $contents{'reasons'}\n";
}
print <<"HTML";
</UL>
</BODY></HTML>
HTML
# Now create an email message and mail it.
$subject = "Travel Plans for " . $contents{'name'};
$sendto = "info@shopsmart.com.au";
# open a named UNIX pipe to send the mail
open (MAIL, "| /usr/sbin/sendmail $sendto") || die "Can't send mail: $!\n";
# This selects the open pipe handle.
select(MAIL);
print <<"EMAIL";
Date: $date
From: $contents{'email'}
To: $sendto
Subject: $subject
Name = $contents{'name'}
Email = $contents{'email'}
Bill-to = $contents{'billto'}
Departure date = $contents{'ddate'}
Departure time range = $contents{'dtime'}
Return date = $contents{'rdate'}
Return time range = $contents{'rtime'}
EMAIL
if($contents{'airline-ind'} eq 'indiffernt') { ; }
else {
print "Airline (first choice) = $contents{'airline1'}\n";
if($contents{'airline2'} ne '') {
print "Airline (second choice) = $contents{'airline2'}\n";
}
}
print <<"EMAIL";
Destination City = $contents{'city'}
Destination State = $contents{'state'}
Smoking preference = $contents{'smoking'}
Reason for trip = $contents{'reasons'}
EMAIL
if($contents{'reasons'} ne '') {
print "Reasons = $contents{'special'}\n";
}
close(MAIL);
exit;
------------------------------
Date: Tue, 14 Jul 1998 12:07:44 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Sendmail ?
Message-Id: <35AB3C00.E8064962@nortel.co.uk>
Sean wrote:
>
> Hello,
>
> I am new to perl and i am trying to get this perl script working to send
> mail, but i keep encountering this error when i click send.
Why do you post it again? Didn't you see the answers that you got?
if (exists(server_error_log)) {
print "read it!";
} else {
$check = run_on commandline;
kill_errors if $check = 'there are errors';
check_out_sendmail if $check = 'could be sendmail';
}
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 14 Jul 1998 07:16:12 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Sendmail ?
Message-Id: <6ofels$5l7$1@earth.superlink.net>
Hello -
"Sean" <info@shopsmart.com.au> writes:
>Hello,
>I am new to perl and i am trying to get this perl script working to send
>mail, but i keep encountering this error when i click send.
>Internal Server Error
>The server encountered an internal error or misconfiguration and was unable
>to complete your request.
>Please contact the server administrator,and inform them of the time the
>error occurred, and anything you might have done that may have caused the
>error.
>I have included a copy of the script below, if someone could give me a clue
>as to what i am doing wrong that would be much apreciated.
Well, there's the syntax error revealed by running the script with the
-cw flags from the command line. Why not fix that error, and then try
again?
The other thing, though, is that you should be using the CGI.pm module,
rather than writing your own routines for every CGI program you write.
David Black
dblack@saturn.superlink.net
------------------------------
Date: Tue, 14 Jul 1998 10:17:01 +0200
From: Nico van Leeuwen <webmaster@acidhouse.com>
Subject: Simple problem with perl script.
Message-Id: <35AB13FC.B2206275@acidhouse.com>
Hi I'm pretty new to perl but I wrote a script and it has a sub routine
it doesn't like I tried some stuff here, I thought it would work but
something seems to be wrong:
# Sub routine check_user
sub check_user {
# Retrieve Data file contents
open (DATAFILE, "$data_file") || die "Can't open $data_file: $!\n";
@lines = <DATAFILE>;
close (DATAFILE);
# Check if same username exists
foreach $line (@lines) {
($username, $2, $3, $4, $5, $6, $7, $8, $9) = split (/:/, $_, 9);
if $username eq $user_login {
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>User already exists!</TITLE></HEAD>\n";
print "<BODY>\n";
print "<FONT SIZE=4>The user-login: $user_login already exists please
choose another</FONT><P>\n";
print "Existing user: $line <P>\n";
print "<A
HREF=\"/cgi-bin/accounts/admin/del-user.cgi?$user_login\">Delete
existing user</A><P>\n";
print "NOTE: If you delete the existing user you will still have to
readd the new user!\n";
print "</BODY></HTML>\n";
exit;
}
}
}
Hope someone can help :o)
Greets,
Nico van Leeuwen
------------------------------
Date: Tue, 14 Jul 1998 10:30:21 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Simple problem with perl script.
Message-Id: <35AB252C.76D399D@nortel.co.uk>
Nico van Leeuwen wrote:
>
> if $username eq $user_login {
That expression should be in brackets. if ($username eq $user_login) {
If you just let the script run in the command line you can already catch
all those error messages.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 14 Jul 1998 12:26:17 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Simple problem with perl script.
Message-Id: <isg1g4lody.fsf@godzilla.kiere.ericsson.se>
Nico van Leeuwen <webmaster@acidhouse.com> writes:
> something seems to be wrong:
I can't drive to work in the mornings, can you tell me why?
> foreach $line (@lines) {
> ($username, $2, $3, $4, $5, $6, $7, $8, $9) = split (/:/, $_, 9);
Take an extra look at what you're splitting, there. Of course, since
you didn't even give us a hint about what the problem is, this may
well be entirely unrelated. For all that I know maybe the problem is
that you didn't turn your computer on.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Tue, 14 Jul 1998 09:46:00 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Urgent!! Need Programmer for perm in Malibu, Ca
Message-Id: <35AB1AC8.FA8774C9@nortel.co.uk>
Rick Koehler wrote:
>
> I believe there's a secret government project to create
> "permafrost" near Malibu ... a vast expanse of frozen tundra,
> complete with musk oxen, arctic hares, and stunted plants.
Hang on...Why would the USA gov do that? I mean, I'd expect anything (I
mean it) from that gov there over the Atlantic, but killing off Malibu?
Isn't that the place where all my idols (like David Hasssselhoffff) sit
and relax and are loved by the gov?
perm could also be short for permutation. I can't even begin to imagine
what that would imply...
------------------------------
Date: Tue, 14 Jul 1998 11:19:07 GMT
From: "I.M.Hay" <i.m.hay@man0524.wins.icl.co.uk>
Subject: w3c/CERN directory protection
Message-Id: <L8Hq1.805$Xt1.3849478@newsr2.u-net.net>
I currently have a directory of html & gifs protected via CERN's/w3c's
htadm. The directory requires a user and password to access the files
contained in it.
Is it possible to protect this directory in such a way so that only one user
'at a time' can access the pages (ie for the time they are logged in via a
browser session)?
Cheers,
Isabel.
------------------------------
Date: 14 Jul 1998 13:35:49 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: w3c/CERN directory protection
Message-Id: <7xoguswtpm.fsf@fidelio.vcpc.univie.ac.at>
Re: w3c/CERN directory protection, I
<i.m.hay@man0524.wins.icl.co.uk> said:
I> I currently have a directory of html & gifs protected via
I> CERN's/w3c's htadm. The directory requires a user and
I> password to access the files contained in it. Is it
I> possible to protect this directory in such a way so that
I> only one user 'at a time' can access the pages (ie for
I> the time they are logged in via a browser session)?
Nope. You don't "log in", you authenticate. Every time a
resource in a protected realm is accessed, your browser must
re-authenticate.
It's not clear what "one at a time" actually means here.
Nor indeed what "user" means. If you could elaborate...
hth
tony
--
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: Tue, 14 Jul 1998 12:43:25 +0100
From: Steve <steve.mortimer@eds.com>
Subject: Re: WebBots
Message-Id: <35AB445D.3E76B358@eds.com>
Darren Sweeney wrote:
> Hi all,
>
> Is there a benefit to using perl/cgi rather than Frontpage WebBots. i need
> to make a decision which one to focus on.
>
> All comments welcomed, thanks
>
Frontpage WebBots are only supported by limited number of ISP's, on the other
hand Perl can be used anywhere and is inherently more flexible and IMHO
generally a better choice.
Steve
> Darren
--
The opinions expressed here are my own
and in no way reflect those of my
employer.
"RAM Disk is NOT and installation Procedure"
------------------------------
Date: 14 Jul 1998 09:49:56 GMT
From: "jim babbington" <jwb79@mail.idt.net>
Subject: Re: What's the substitute for #! /usr/bin/perl in Win32 Perl?
Message-Id: <01bdaf0b$b3faa190$6488fdc7@dixon>
James,
If you associate the .pl for the "open function" somthing like:
c:\perl\bin\perl.exe -S %1 %*
and enter the entire filename(w/.pl) at the command line, NT will find your
script in your PATH and launch it. (the -S says search PATH for the script,
the %1 will be substituted with <script> and the %* will pass command line
arguments).
Hope this helps,
Jim
------------------------------
Date: Tue, 14 Jul 1998 08:46:13 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Why is Dave operating here? (was Re: REPOST: Re: )
Message-Id: <35ab1833.3530743@news.tornado.be>
John Stanley wrote:
>Do you really not
>know that Dave is a program and not a person?
You mean: just like Tom Phoenix?
;-)
Bart.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3151
**************************************