[9080] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2699 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 23 00:08:46 1998

Date: Fri, 22 May 98 21:01:39 -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           Fri, 22 May 1998     Volume: 8 Number: 2699

Today's topics:
        Help with CGI and shell execution braunb@my-dejanews.com
    Re: help (Charles DeRykus)
    Re: How to execute a system command from Perl (NT) <sowmaster@juicepigs.com>
    Re: Idle thoughts...Can I make this leap year function  (Ken Williams)
    Re: More double standards out of the FSF (Ken Williams)
    Re: More double standards out of the FSF <hp@pobox.com>
        Please Help <anw3635@omega.uta.edu>
    Re: Re-direct question (Phil)
    Re: Re-direct question <lr@hpl.hp.com>
    Re: Re-direct question (Phil)
    Re: Suggestion Re: GNU attacks on the open software com (Ken Williams)
    Re: Timeout problem <lr@hpl.hp.com>
    Re: Tom Christiansen attacks the free software communit (Marek Jedlinski)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 23 May 1998 02:24:47 GMT
From: braunb@my-dejanews.com
Subject: Help with CGI and shell execution
Message-Id: <6k5c1f$k67$1@nnrp1.dejanews.com>

Hello,

I have a CGI program that allows end users to change their password on the
fly.  The program works great except for one little thing, I can't get it
to execute the make in /var/yp to make and push out the password file.
I consistently get "No such file or directory" as a return value from
my system call.  I've tried setting the Path via the ENV variable with
no luck.  I've tried using qx as well as system with no success.  I've
tried running the script set uid as well as non-set uid.
Is there some fact that I'm missing about doing a system or a backtick
call out of a CGI script? Is there something on the web server that needs
to be set???  I also notice that occasionally, I get a Netscape error
(I'm using the Netscape 4.0.4 browser) about "Document contains no data",
which I am assuming is an error with the system call passing bogus text
back to the Apache server, which promptly barfs.

Help me, please...:-)

My particulars:

Hardware - Solaris 2.5.1 UltraSparc 2
Web server - Apache 1.3B6
Perl version 5.004-04
Braun Brelin
bbrelin@dnai.com



-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


------------------------------

Date: Sat, 23 May 1998 01:57:44 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: help
Message-Id: <EtE048.2D7@news.boeing.com>

In article <3564D013.2737CA2@world.std.com>,
Fred Lovine  <flovine@world.std.com> wrote:
 > I am using Perl 5.003 on both NT and Solaris platforms.
 > I am also using Perl 4.0 on HP-UX
 > 
 > The following code works on the HP, but not NT or Solaris.
 > When the file "xx" does not execute permission the code should
 > return: "command failed: Permission denied", but on NT and Solaris
 > I get: "command failed:"
 > 
 > Note: This code is directly from the book "Programming Perl"
 > 
 > $rc = 0xffff & system("./xx");
 > if ($rc == 0) {
 >     print "ran with normal exit\n";
 > }
 > elsif ($rc == 0xff00) {
 >     print "command failed: $!\n";
 > }
 > elsif ($rc > 0x80) {
 >     $rc >>= 8;
 >     print "ran with non-zero exit status $rc\n";
 > }
 > else {
 >     print "ran with ";
 >     if ($rc & 0x80) {
 >         $rc &= ~0x80;
 >         print "coredump from ";
 >     }
 >     print "signal $rc\n"
 > }
 > 
 > 

Hm, puzzling results. However, here's a possible fork and 
exec workaround:


if (my $pid = fork) {
   1 until (my $kid = wait) == $pid;
   if ($? == 0) {
        print "ran with normal exit\n";
   } elsif($? == 0xff00) {
        print "command failed: $!\n";
   } elsif ($? > 0x80) {
        print "ran with non-zero exit status: ", $? >> 8, "\n";
   } else {
       if ($? & 0x80) {
           $? &= ~0x80;
           print "coredump from ";
       }
       print "signal $?\n"
   }
} elsif (defined $pid) {
      exec "./xx" or exit $!; 
} else {
      die "fork failed: $!";
}
__END__

This prints:

   Can't exec "./xx": Permission denied at ./tmp3.perl line 22.
   ran with non-zero exit status: 13

To decipher the return code 13:  

   perl -e '$! = 13; print "$!\n"'  which prints "Permission denied". 


HTH,
--
Charles DeRykus


------------------------------

Date: Fri, 22 May 1998 22:59:56 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Ed Costello <costello@hyperspectral.com>
Subject: Re: How to execute a system command from Perl (NT)
Message-Id: <35663BAC.4BD9@juicepigs.com>

Ed Costello wrote:
> 
> Suppose I have a system command assigned to a Perl variable.
> 
> For example,
> % $cmd = "programname -a1 -b2 -c3";
> 
> How can I execute this command from within the Perl script.  I tried
> several permuations of $cmd, $$cmd, etc. but with no luck.  Is this
> possible with Perl/NT?


perldoc -f system
perldoc -f exec


-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


------------------------------

Date: Fri, 22 May 1998 22:17:11 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Idle thoughts...Can I make this leap year function more elegant/efficient?
Message-Id: <ken-2205982217110001@news.swarthmore.edu>

In article <356749eb.14708245@cnews.newsguy.com>, fritz.knack@POPULUS.net wrote:

>I compacted this one as much as *I* could, but I couldn't help but
>wonder if there was a "better way" or something that may use an idiom
>with which I'm not familiar.
>
>I'm not terribly worried about detecting past leap years; in
>particular, the year we started using the Gregorian calendar doesn't
>matter in the context in which this function lives. Given that, a leap
>year is any year divisible by 4 unless it's a 100 year, in which case
>it must also be divisible by 400. (1800, 1900, 2100, 2200 aren't leap
>years, but 2000 is.)
>
>
>#---------------------------------------------
>sub is_leap {
>    my $year = shift;
>    return (
>        !($year % 4) &&
>        (!($year % 100) ? !($year % 400) : 1)
>    );
>}
>#---------------------------------------------

You can do a little boolean algebra on it to get rid of the !'s.  Here are
the simplification steps:

     !($year % 4) &&
     (!($year % 100) ? !($year % 400) : 1)

    not not(
     !($year % 4) &&
     (!($year % 100) ? !($year % 400) : 1)
    )

    not (
     ($year % 4) ||
     !(!($year % 100) ? !($year % 400) : 1)
    )

    not (
     ($year % 4) ||
     (!($year % 100) ? ($year % 400) : 0)
    )

    not (
     ($year % 4) ||
     (($year % 100) ? 0 : ($year % 400))
    )

    not ($year % 4 or ($year % 100) ? 0 : ($year % 400))



In general, whenever you've got a construct like this:
  !$condition ? $result1 : $result2

You could rewrite it like this:
   $condition ? $result2 : $result1


That ? 0 : is nagging me though, I think we might be able to get rid of that...

    not ($year % 4 or !($year % 100) ? ($year % 400) : 0)

    not ($year % 4 or !($year % 100) and ($year % 400))

Which I see is totally identical to Tom Rokicki's solution, distributing
the not:

    not $year % 4 and not !($year % 100) or not ($year % 400)

    not $year % 4 and ($year % 100) or not ($year % 400)

    !($year % 4) and ($year % 100) or !($year % 400)

Ah well...


------------------------------

Date: Fri, 22 May 1998 23:01:31 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: More double standards out of the FSF
Message-Id: <ken-2205982301310001@news.swarthmore.edu>

In article <wsnra1m1eu5.fsf@harper.uchicago.edu>, robert havoc pennington
<hp@pobox.com> wrote:
>(The perl docs clearly fail the "modifiable" test, and maybe fail the
>other two - the license and what Tom says seem to be a slightly out of
>sync on that, but he has promised to clarify in future versions.)

I have to wonder - why would people want the documentation to be freely
modifiable anyway?  I shudder to imagine Perl documentation designed by a
committee.  So dry.

It seems like the centralized model of evolving documentation is better -
if you want to change a piece of writing, get the original author to
accept your submission.  Otherwise, write your own documentation and
distribute it seperately.  I guess this is what RMS wants to do.

I'm curious - given that documentation is often much closer to being a
work of prose than a piece of software, why should it be subject to the
GPL at all?  We'd have some pretty horrible novels if they were governed
by public licenses.  

Is it because the documentation is closely linked with the software
itself?  I think the line between a piece of software and its
documentation usually remains pretty crisp, so it's pretty easy to cover
them under seperate licenses.  Anyway, I'm interested in hearing people's
opinions on why the docs should fall under GPL or its kin.


------------------------------

Date: Sat, 23 May 1998 03:37:51 GMT
From: robert havoc pennington <hp@pobox.com>
Subject: Re: More double standards out of the FSF
Message-Id: <wsng1i11wts.fsf@harper.uchicago.edu>

ken@forum.swarthmore.edu (Ken Williams) writes:
> 
> It seems like the centralized model of evolving documentation is better -
> if you want to change a piece of writing, get the original author to
> accept your submission. 

Most freely modifiable docs work just this way. It's a matter of legal
guarantees for the future, and the ability to fork, rather than any
practical difference in day-to-day development/writing.

> I'm curious - given that documentation is often much closer to being a
> work of prose than a piece of software, why should it be subject to the
> GPL at all?  We'd have some pretty horrible novels if they were governed
> by public licenses.  
>

The claim is that if the software is modifiable, but the docs aren't,
that modifying the software requires starting the docs from
scratch. When there are 1000 pages of docs, this makes modifying the
software in a significant way a Herculean task. Software is pretty
hard to use without docs. This rationale obviously does not apply to
novels.

Counterarguments include the claim that you can include addenda -
which might work but seems suboptimal. 

It is all somewhat academic because the Perl community seems to be
going along fine as is; however, many feel the need for a guarantee,
and a firm definition of software which is free vs. not free. If you
start making exceptions because so-and-so developer does a good job,
or the software is "almost free," then there is a fear of a slippery
slope effect.

There does seem to be a de facto exception in place, however, because
no one is getting motivated enough to write new perl docs.

Oh, FWIW apparently the FSF does not use the GPL for docs, but they do
use a license that allows modifications.

Havoc Pennington ==== http://pobox.com/~hp


------------------------------

Date: Fri, 22 May 1998 20:31:06 -0400
From: Ann <anw3635@omega.uta.edu>
Subject: Please Help
Message-Id: <356618CA.D73DB4D0@omega.uta.edu>

For the life of me I cannot get this to run, all it is suppose to do is
take info from the web which it does fine and then create a .forward
file in the home dir of the user, which it never does and for the life
of me I cannot figure out why.
#!/usr/bin/suidperl
$ENV{'PATH'} = '/bin:/home/$user';
print "Content-type: text/plain", "\n\n";
$query_string = $ENV{'QUERY_STRING'};
print "$query_string\n";

($var1, $var2) = split(/&/, $query_string);
print "$var1, $var2\n";

($field1, $user) = split(/=/, $var1);
print "$field1, $user\n";

($field2, $fw) = split(/=/, $var2);
print "$field2, $fw\n";

$fw = "$user:$fw";
exec "/bin/echo", $fw > "/home/$user/.forward";



------------------------------

Date: Sat, 23 May 1998 02:18:31 GMT
From: pbuckley@tiac.net (Phil)
Subject: Re: Re-direct question
Message-Id: <3566319b.1995405@news.tiac.net>

On Fri, 22 May 1998 23:40:01 GMT, Tom Phoenix <rootbeer@teleport.com>
wrote:

>On Fri, 22 May 1998, Larry Rosler wrote:
>
>> if ($host =~ /\Q$res_dom\E$) {   # If they are coming from Varian
>
>So, you'd treat connections from notvarian.com and
>varian.com.haha.students.bedrock.edu as coming from varian? Hmmm... I
>think there's a better way to identify a domain. :-)

Actually, I DO want to keep out more varians than just "varian.com",
the main one I am looking to restrict is "iis.varian.com".

Would it be easier via IP range???


------------------------------

Date: Fri, 22 May 1998 20:19:34 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Re-direct question
Message-Id: <6k5f90$kdl@hplntx.hpl.hp.com>

Phil wrote in message <3566319b.1995405@news.tiac.net>...
>On Fri, 22 May 1998 23:40:01 GMT, Tom Phoenix <rootbeer@teleport.com>
>wrote:
>
>>On Fri, 22 May 1998, Larry Rosler wrote:
>>
>>> if ($host =~ /\Q$res_dom\E$) {   # If they are coming from Varian
                               ^ typo: / missing before the )
>>
>>So, you'd treat connections from notvarian.com and
>>varian.com.haha.students.bedrock.edu as coming from varian? Hmmm... I
>>think there's a better way to identify a domain. :-)
>
>Actually, I DO want to keep out more varians than just "varian.com",
>the main one I am looking to restrict is "iis.varian.com".
>
>Would it be easier via IP range???

I doubt it.

Tom Phoenix caught my omission of a guard over the front end of this
regex, but apparently missed the $ at the back end, which would rule out
the students from Bedrock.  How about this:

if ($host =~ /(?:^|\.)\Q$res_dom\E$/) {   # If they are coming from
Varian

One might go further and require that the first dot be preceded by at
least one character from the set of characters acceptable in a domain
name (according to the RFC), but I think the regex as it is above is
sufficient for this problem.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





------------------------------

Date: Sat, 23 May 1998 03:55:33 GMT
From: pbuckley@tiac.net (Phil)
Subject: Re: Re-direct question
Message-Id: <356647df.4747173@news.tiac.net>

Thnaks for all the help Larry, but I can't get this damn script to
hold me out (I change it to my ISP's domain to check it).

This seemed so simple when I thought of it yesterday :(

It just lets me go to the "private.shtml" page, any other ideas of a
way to accomplish this?

Here is how I currently have it:
################################################################
# Variables

$res_dom = "varian.com";
$varian_url = "http://www.tiac.net/users/dam4/varian.shtml";
$other_url = "http://www.tiac.net/users/dam4/private.shtml";

################################################################

$host = "$ENV{'REMOTE_HOST'}";

if ($host =~ /(?:^|\.)\Q$res_dom\E$/) {  # If they are coming from
Varian
   print "Location: $varian_url\n\n";
} 
else {                                   # For any other domain
   print "Location: $other_url\n\n";
}


TIA,
Phil


On Fri, 22 May 1998 20:19:34 -0700, "Larry Rosler" <lr@hpl.hp.com>
wrote:

>Phil wrote in message <3566319b.1995405@news.tiac.net>...
>>On Fri, 22 May 1998 23:40:01 GMT, Tom Phoenix <rootbeer@teleport.com>
>>wrote:
>>
>>>On Fri, 22 May 1998, Larry Rosler wrote:
>>>
>>>> if ($host =~ /\Q$res_dom\E$) {   # If they are coming from Varian
>                               ^ typo: / missing before the )
>>>
>>>So, you'd treat connections from notvarian.com and
>>>varian.com.haha.students.bedrock.edu as coming from varian? Hmmm... I
>>>think there's a better way to identify a domain. :-)
>>
>>Actually, I DO want to keep out more varians than just "varian.com",
>>the main one I am looking to restrict is "iis.varian.com".
>>
>>Would it be easier via IP range???
>
>I doubt it.
>
>Tom Phoenix caught my omission of a guard over the front end of this
>regex, but apparently missed the $ at the back end, which would rule out
>the students from Bedrock.  How about this:
>
>if ($host =~ /(?:^|\.)\Q$res_dom\E$/) {   # If they are coming from
>Varian
>
>One might go further and require that the first dot be preceded by at
>least one character from the set of characters acceptable in a domain
>name (according to the RFC), but I think the regex as it is above is
>sufficient for this problem.
>
>--
>Larry Rosler
>Hewlett-Packard Laboratories
>lr@hpl.hp.com
>
>
>



------------------------------

Date: Fri, 22 May 1998 21:19:22 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Suggestion Re: GNU attacks on the open software community
Message-Id: <ken-2205982119220001@news.swarthmore.edu>

>>}But instead of trying to get him to rewrite his license, I think
>>}it would be nice if the FSF changed their statement to read
>>}something like:
>
>>Why should the FSF type one keystroke to pander to someone who is too
>>lazy to read their definition of "free"?  

Hmmm...  I don't think it's a question of laziness.  I think it's far more
likely that someone will read a statement that says that some software or
other is "free," and think they know what it means.  If someone told them
"hey, be careful, 'free' may not mean what you think it means," I'm sure
they wouldn't be too lazy to read their definition.

Case in point - I've been a Perl programmer for several years, but until
today I had no clue that "GNU free" didn't mean "money free".  I mean, I
knew it meant open source and all that, but I assumed it mainly meant free
of charge, and that all the open source stuff just sort of followed from
that.  I had no reason to ask.  I guess I've been ignorant in that
respect, probably much more so than many people here.

But I kind of _like_ being ignorant about this - it's like, if I can take
for granted my right to free speech for a while, I think that's some kind
of triumph of our society.

But don't take the above too seriously - after all, I'm blissfully ignorant. =)


------------------------------

Date: Fri, 22 May 1998 19:57:40 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Timeout problem
Message-Id: <6k5dvu$jvn@hplntx.hpl.hp.com>

Charles DeRykus wrote in message ...
>In article <6k4rmm$2f9$1@baker.cc.tut.fi>,
>Tommi Reiman  <tkr@assari.cc.tut.fi> wrote:
>>  How could I set out a timeout for a function so that if it dosn't
return
>>a value in $timeout seconds, the function will be 'killed'??
>
>perldoc -f alarm
>
>On most non-Unix systems though, alarm's not available.
>
>--
>Charles DeRykus

Can one conclude therefore that this problem has no solution on must
non-Unix systems?

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





------------------------------

Date: Sat, 23 May 1998 02:11:40 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: Tom Christiansen attacks the free software community (was: Re: GNU attacks on the open software community)
Message-Id: <35660779.6239803@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.

galibert@pobox.com (Olivier Galibert)  wrote:

>In article <6k2ur0$jut$1@csnews.cs.colorado.edu>, Tom Christiansen wrote:
>>I'm sorry Barry, but when Joe Anybody hears the word "free", his thought
>>is "gratis", not "libre".  Go ask someone on the street what a "free
>>lunch", a "free computer", a "free hamburger", or some "free software"
>>are.  Heck, I'll bet they even get the wrong idea about "free rooms".
>>Go ahead.    This is all very misleading.
>
>Then  ask anybody about "free speech"  or  "freedom of press". This is
>only a matter of context. 

Yes.

speech, press -> abstract nouns. "Free" qualifying an abstract noun will be
understood as "libre" by default.

computer, hamburger -> concrete nouns, tangible objects. With these, "free"
will be taken to mean "gratis", by default.

>The bad  thing being that for software, both
>are valid.

For software, yes. For *documentation*, no.

I'll grant that "documentation" is in a gray area between abstract and
concrete, but it tends toward the latter. You and I are aware of the
potential ambiguity, but "most people" aren't. For "most people", free
documentation will mean "gratis" by default, unless clearly expalined
otherwise.

>For text coming straight from the gnu's web  pages, no matter what you
>say, said context is unmistakable.

Provided you have previous knowledge of the issues involved (i.e. you know
about Stallman, GNU, FSF et al).

Let me ask you this. The FSF web page states that perl documentation is not
free, in their well-defined meaning of the word. What if somebody read the
same statement in a paper or a computer magazine? There's *is* potential
for confusion, denying it is counterproductive, seeing as how painlessly
the confusion may be avoided by either rephrasing the FSF wording or by
providing a visible pointer to the FSF definition of 'free' at the top or
bottom of the page in question.

 .marek


-- 
Invalid thought. Close all mental processes and restart body.
Largactil Cafi http://www.lodz.pdi.net/~eristic/index.html
Send message with GET PGP_KEY in subject for PGP public key.
Hail Eris. *plonk* trolls. Fight spam: http://www.cauce.org/



------------------------------

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 2699
**************************************

home help back first fref pref prev next nref lref last post