[16217] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3629 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 11 21:10:29 2000

Date: Tue, 11 Jul 2000 18:10:20 -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: <963364220-v9-i3629@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 11 Jul 2000     Volume: 9 Number: 3629

Today's topics:
        I print localtime and get seconds. Great!  But in my sc (Ariel Lia)
    Re: I print localtime and get seconds. Great!  But in m newsposter@cthulhu.demon.nl
    Re: I print localtime and get seconds. Great!  But in m (Cameron Kennedy)
    Re: I print localtime and get seconds. Great!  But in m <lr@hpl.hp.com>
        Is this an application for PERL?? <ra5589@email.sps.mot.com>
    Re: Jeopardy Quoting [Was: <newbie>How to determine cur <DNess@Home.Com>
    Re: Method to obfuscate or disguise Perl source code? (Abigail)
    Re: Method to obfuscate or disguise Perl source code? <care227@attglobal.net>
    Re: Method to obfuscate or disguise Perl source code? <care227@attglobal.net>
    Re: multidimensional associative arrays (Abigail)
    Re: Newbie - Read in chunks of data <lr@hpl.hp.com>
        Non-blocking reads in Win32 (Dave)
    Re: Open and print file? <lauren_smith13@hotmail.com>
    Re: Open and print file? (Gwyn Judd)
    Re: Open and print file? (Craig Berry)
        Problem running first perlxstut example grey1969@my-deja.com
    Re: qw and delimiter usage <nnickee@nnickee.com>
        Reloading config file under Apache::Registry <glchyNOglSPAM@cc21.com.sg.invalid>
    Re: running system command as root from perl (brian d foy)
    Re: running system command as root from perl ynotssor@my-deja.com
    Re: running system command as root from perl <troyNO@SPAM.troysplace.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Jul 2000 18:49:58 -0400
From: Ariellia@garden.com (Ariel Lia)
Subject: I print localtime and get seconds. Great!  But in my script, seconds convert to DMDTY
Message-Id: <A9CB10141E703D04.D27A4EE0A7723E42.89DA4C81570F478B@lp.airnews.net>

Hi!

In the script below, I am using the localtime variable to give me a 
unique number to assign to 2 variables that need unique numbers.

If I just print localtime to stdout, I get a string of just seconds.

But in my html output, the seconds get converted to: Tue Jul 11 18:39:42 
2000

If you notice, I even insert localtime into the $seccs variable...but my 
results are lacking.

Any tips?

Thanks!

Ariel Lia (please don't laugh at my UGLY UGLY NEWBIE CODE :-)


$seccs = localtime;
$name1 = $seccs;
$name2 = $seccs;

$infilename = 'c:\replace.txt';
$outfilename = 'c:\replace2.txt';

$search = '<!--replace-->';

$replace = '<!--begin--><FONT face="times new roman" size="3" 
color="white" edittag="' . $name1. '">
<edittag name=$name2 type="Area" Prompt="Paste or Type Next Status Report 
below' .  $name2 .'" pos=top>
<pre><h3>Header</h3>Paragraphs here</pre></EDITTAG></font><!--end-->
<!--replace-->';


open(IN,$infilename) ||
  die "cannot open $infilename for reading: $!";
## optional test for overwrite...
## die "will not overwrite $outfilename" if -e $outfilename;
open(OUT,">$outfilename") ||
  die "cannot create $outfilename: $!";
while (<IN>) { # read a line from file IN into $_
  s/$search/$replace/g; # change the lines
  print OUT $_; # print that line to file OUT
}
close(IN);
close(OUT);

print (localtime);

# system("copy $outfilename $infilename");


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

Date: 11 Jul 2000 22:55:58 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: I print localtime and get seconds. Great!  But in my script, seconds convert to DMDTY
Message-Id: <8kg8lu$7kv$1@internal-news.uu.net>

Ariel Lia <Ariellia@garden.com> wrote:

> If I just print localtime to stdout, I get a string of just seconds.

> But in my html output, the seconds get converted to: Tue Jul 11 18:39:42 
> 2000

perldoc -f localtime

    In a scalar context, prints out the ctime(3) value

    non scalar: returns a 9-element array,

So you do _not_ get just seconds, you actually get an array. Print
is so kind to print the elements without space in between so that it
looks like a long number.

If you want to get seconds, have a look at the 'time' function.

perldoc -f time

Erik



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

Date: Tue, 11 Jul 2000 16:00:05 -0800
From: kenned57@pilot.msu.edu (Cameron Kennedy)
Subject: Re: I print localtime and get seconds. Great!  But in my script, seconds convert to DMDTY
Message-Id: <kenned57-1107001600050001@alexthinkpad.salk.edu>


> In the script below, I am using the localtime variable to give me a 
> unique number to assign to 2 variables that need unique numbers.

> 
> $seccs = localtime;
> $name1 = $seccs;
> $name2 = $seccs;
> 

You are using localtime time in a scalar context.  Which produces
something similar to Tue Jul 11 15:52:24 2000, and is often quite useful
in itself.

one way to get the number you want
$name1=join'',localtime;   
$name1 is 34541511610021920.

Cameron


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

Date: Tue, 11 Jul 2000 16:16:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I print localtime and get seconds. Great!  But in my script, seconds convert to DMDTY
Message-Id: <MPG.13d54a8deb46c59c98abbb@nntp.hpl.hp.com>

In article 
<A9CB10141E703D04.D27A4EE0A7723E42.89DA4C81570F478B@lp.airnews.net> on 
Tue, 11 Jul 2000 18:49:58 -0400, Ariel Lia <Ariellia@garden.com> says...
 
> In the script below, I am using the localtime variable to give me a 
> unique number to assign to 2 variables that need unique numbers.

Are you sure you want to use localtime(), or just time()?

perldoc -f time

> If I just print localtime to stdout, I get a string of just seconds.
> 
> But in my html output, the seconds get converted to: Tue Jul 11 18:39:42 
> 2000
> 
> If you notice, I even insert localtime into the $seccs variable...but my 
> results are lacking.

 ...

> $seccs = localtime;

This is scalar context, so you get a string.

 ...

> print (localtime);

This is list context, so the program prints all the digits of the output 
list sequentially.  This is not 'a string of just seconds'.

You really should have read the documentation for localtime() before 
posting a question about it!

perldoc -f localtime

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 11 Jul 2000 17:37:13 -0700
From: Peter Brooker <ra5589@email.sps.mot.com>
Subject: Is this an application for PERL??
Message-Id: <396BBDB9.1DC59A08@email.sps.mot.com>

I have an application that produces a numerical sequence of *.gif files.

The sequence looks like

n1_dio_001.gif
n1_dio_002.gif
 .
 .
n1_dio_xxx.gif, 50 < xxx < 200

I do this frequently and consequently I want to write a script that will

create an html file to display these gifs in sequence. This file will
work as follows. When the user clicks on the html file, he/she will see
the first gif file with a forward and backward arrow at the bottom of
the screen. Clicking on the forward arrow will allow the user to display

the next gif image. The backward arrow will display the previous image
in the sequence.

I am guessing that a PERL script could be created that could
"automatically" create the html file. Am I correct?

Is using a PERL script a good way to go?

thanks-Peter Brooker





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

Date: Tue, 11 Jul 2000 23:20:28 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Jeopardy Quoting [Was: <newbie>How to determine current ...]
Message-Id: <396BABA4.96821D29@Home.Com>

Jeff Susanj wrote:
> 
> This "Jeopardy Quoting" must be a perl thing because I have never heard
> anyone object to it in any other newsgroup.  I really hate to wade through a
> big long quote when I just read it in the last 10 replies.  The quote is a
> reference that I can look at if I need it.  Otherwise I know what the thread
> is about.  Worse, I hate to see someone blasted for something like that
> especially with no explanation (as I was in another Perl newsgroup that I
> never went back to).
> 
> Jeff S.
> 

The show `Jeopardy' prides itself on being backwards (answer comes before
question). That's why putting your comment _before_ the thing being commented
on is called `Jeopardy Quoting'.

You are welcome to prefer presenting information any way you like. Your
arguments have been made countless times before and are _very_ familiar to
everyone. Some newsgroups don't care about the `style' of communications.

However, some newsgroups do have a pronounced style and this is one of them. 
The people who do the heavy lifting here (I am not one of them, BTW) are used 
to reading things their way, so if you want answers you'd be well advised to
follow _their_ rules. They really read a lot of mail, and switching between
some people Jeopardy Quoting and others not doing so is a real PITA to them
and it is their help that we all want. So it's best to do things _their_ way
when you want their help. In some other newsgroup where you are doing the
heavy lifting you can ask people to do things _your_ way.

Some usenet groups don't care. Some even _like_ Jeopardy Quoting. This one
doesn't like it. I'd advise you to follow local conventions once you are 
informed of them.


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

Date: 11 Jul 2000 18:07:51 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <slrn8mn7n5.am3.abigail@alexandra.delanet.com>

Drew Simonis (care227@attglobal.net) wrote on MMDVI September MCMXCIII in
<URL:news:396B8608.8AAB5ED8@attglobal.net>:
<> Tad McClellan wrote:
<> > 
<> > You don't have to "copyright" it.
<> > 
<> > If you write it, it is already copyrighted by you (you don't have
<> > to "do anything" to get it copyrighted. You may have to do something
<> > to _keep_ the copyright though).
<> > 
<> > (of course, all of that depends on what country you live in...)

Only in a technical sense. Most countries have signed the Berne convention,
which covers copyright. The US was one of the last countries to sign.

<> > I think "license" is the term Drew was (or should have been anyway)
<> > looking for.
<> > 
<> 
<> Neh, I meant copyright.  You are correct, you don't _have_ to 
<> do anything but author the program to have copyright rights, but 
<> a copyright in the work of authorship is not legally defendable
<> in the US.  In order to secure legal protection of a copyright
<> (the thrust of my post) that copyright _must_ be registered.

No, that would be a violation of the Berne convention. Registration
might be useful to prove you have the copyright, but you don't lose
rights for not registering.



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Tue, 11 Jul 2000 18:52:10 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396BA51A.27760269@attglobal.net>

Jerome O'Neil wrote:
> 
> > Neh, I meant copyright.  You are correct, you don't _have_ to
> > do anything but author the program to have copyright rights, but
> > a copyright in the work of authorship is not legally defendable
> > in the US.  In order to secure legal protection of a copyright
> > (the thrust of my post) that copyright _must_ be registered.
> 
> The law states that registration prevents an infringer from
> claiming innocence due to ignorance in his defence.  It has
> to do with your right to recover damages.  The work is always
> protected.

Thats what I was saying.


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

Date: Tue, 11 Jul 2000 18:56:24 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396BA618.B8DC381E@attglobal.net>

Abigail wrote:
> 
> Drew Simonis (care227@attglobal.net) wrote on MMDVI September MCMXCIII in
> <>
> <> Neh, I meant copyright.  You are correct, you don't _have_ to
> <> do anything but author the program to have copyright rights, but
> <> a copyright in the work of authorship is not legally defendable
> <> in the US.  In order to secure legal protection of a copyright
> <> (the thrust of my post) that copyright _must_ be registered.
> 
> No, that would be a violation of the Berne convention. Registration
> might be useful to prove you have the copyright, but you don't lose
> rights for not registering.
> 

What I am saying is that there is the obvious implied copyright.
Then there is the registered copyright.  If party A copies (without
my consent) my code, my copyright is in effect, but what can i do?
Issue a cease and desist order?  If I want to collect damages (legally
defend, in my thinking) the copyright must be registered.  I suppose
it is a semantic argument, since any action taken on behalf of my 
copyright can be considered legal action, but when I said "jealously
defend" in my origional comment on this matter, I had the idea of 
collecting damages in mind.


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

Date: 11 Jul 2000 18:09:47 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: multidimensional associative arrays
Message-Id: <slrn8mn7qp.am3.abigail@alexandra.delanet.com>

Philip Rennert (phil.rennert@ioip.com) wrote on MMDVI September MCMXCIII
in <URL:news:396B65ED.C1F2E55E@ioip.com>:
~~
~~ (Sorry I didn't state it more clearly.)


You're still quoting Jeopardy style. Don't do that if you desire an
answer.


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Tue, 11 Jul 2000 15:34:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie - Read in chunks of data
Message-Id: <MPG.13d540d361dabc898abb8@nntp.hpl.hp.com>

[By putting 'Newbie' in your subject, you have caused many newsreader 
filters to hide your post from others who might otherwise answer it.]

In article <8kfm69$900$1@nnrp2.deja.com> on Tue, 11 Jul 2000 17:40:23 
GMT, moria6@my-deja.com <moria6@my-deja.com> says...
> I have a file of hex data that I would like to
> read in 4 bytes at a time and perform a hex-->
> decimal conversion on.  Then I'd like to write
> these decimal numbers out to a file.

What do you mean by 'hex data'?  I will assume you mean 'binary data' 
that you sometimes choose to look at as if each four bytes were 
represented by sequences of eight hex digits.

> When I went to open the file and store it to an
> array I discovered that the file is one 18K+
> chars long line.  I was hoping to 'while-loop' my
> way through that 4 bytes at a time and then write
> to an array and subsequently an ASCII file with a
> newline char after each decimal number.

You can use the read() function to read four bytes at a time, or you can 
set the input record separator $/ to \4 and use the while-loop.  Why 
bother with the array, when you can write the results out as they are 
computed?

    binmode IN;
    print OUT unpack('N' => $_), "\n" while read IN, $_, 4;

The above assumes 'network' byte order on the file (high-order byte of 
each quartet is first).

> I have the 'easy' parts done in knowing how to
> open the original file for read, check to see if
> the output file exists (if not create it) and
> open it for write access.

No need to check for existence of the output file; just open it for 
output, which creates it if it doesn't exist.

>                            I also 'think' I know
> how to accomplish the hex-->dec conversion.

perldoc -f pack
perldoc -f unpack
 
> Any help is greatly appreciated!

HTH

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 12 Jul 2000 00:04:50 GMT
From: dfriend@davegate.dave.net (Dave)
Subject: Non-blocking reads in Win32
Message-Id: <slrn8mms21.gju.dfriend@cb518253-a.rchstr1.mn.home.com>

I apologize if this is in a FAQ somewhere, but I've looked for several days and
couldn't come up with a definitive answer.  So....

Is it possible *at all* to do non-blocking reads on a filehandle in Win32?  I'm
porting a script from linux which uses Fcntl to make a socket non-blocking, and
it works just fine on linux.  Fcntl is apparently not implemented in Win32 so
that won't work.  I saw that IO::Handle in newer versions of perl have a
blocking() method, but that doesn't seem to work either.

I wouldn't *need* non-blocking reads to work if filevent() in the Tk module
worked in Win32, but that doesn't seem to work either.  It works on linux
for both blocking and non-blocking filehandles, so I wouldn't think they two
are related, but they both point to pretty deficient file handling on Win32.

Any help anyone could offer would be appreciated.  I would of course also be
interested in how people handle situations in Win32 that would otherwise be
done with non-blocking IO.  Thanks.



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

Date: Tue, 11 Jul 2000 15:53:08 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Open and print file?
Message-Id: <8kg8i4$dn6$1@brokaw.wa.com>


langtind <arild@langtind.no> wrote in message
news:%rMa5.2548$Dxe.186298368@news.telia.no...
> Hi!
> I just wonder how I open and print a file (with Perl) with several lines.
I
> have only made to print out the first line.
> Yes, I know you think it's simple, but I need some help.

Something like:

#!perl -w
use strict;

my $filename = "something.ext";
open FILE, $filename or die "$filename: $!";

while (<FILE>) {
   print;
}

?

Have you thought of getting a book like Learning Perl by Randal Schwartz or
Elements of Programming With Perl by Andrew Johnson?  Both are highly
recommended for new programmers.

Lauren





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

Date: Wed, 12 Jul 2000 00:18:56 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Open and print file?
Message-Id: <slrn8mnebd.1ta.tjla@thislove.dyndns.org>

I was shocked! How could langtind <arild@langtind.no>
say such a terrible thing:
>Hi!
>I just wonder how I open and print a file (with Perl) with several lines. I
>have only made to print out the first line.
>Yes, I know you think it's simple, but I need some help.

You mean like this:

perl -pe '' some_file_to_print

?

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Next Friday will not be your lucky day.  As a matter of fact, you don't
have a lucky day this year.


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

Date: Wed, 12 Jul 2000 00:52:59 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Open and print file?
Message-Id: <smngbbpqnd6121@corp.supernews.com>

langtind (arild@langtind.no) wrote:
: I just wonder how I open and print a file (with Perl) with several lines. I
: have only made to print out the first line.
: Yes, I know you think it's simple, but I need some help.

Everybody starts with baby steps.  The best way to get help is to develop
a short program that displays this misbehavior, cut and paste it into a
message, and describe what you think is going on.  You'll find people are
more willing to help with (small, well-focused) debugging problems than
general "show me how" requests.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: Tue, 11 Jul 2000 22:23:59 GMT
From: grey1969@my-deja.com
Subject: Problem running first perlxstut example
Message-Id: <8kg6pc$b22$1@nnrp1.deja.com>

I am having problems with making the first perlxstup example, and I
hope somebody can help out.  I've been through the newsgroups, but I
haven't found anything that clears up my question.

I run the perl Makefile.PL, and I get the message:

Writing Makefile for Mytest

after that I run the make, and I get the following error:

Mytest.xs:13: parse error before `:'
make: *** [Mytest.o] Error 1

the file contents of Mytest.xs are:

        #ifdef __cplusplus
        extern "C" {
        #endif
        #include "EXTERN.h"
        #include "perl.h"
        #include "XSUB.h"
        #ifdef __cplusplus
        }
        #endif



        PROTOTYPES: DISABLE

        MODULE = Mytest         PACKAGE = Mytest

void
hello()
        CODE:
        printf("Hello, world!\n");


I would appreciate it if someone could offer some suggestions, or point
me to some documentation that could help out.  Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 11 Jul 2000 17:33:22 -0500
From: Nnickee <nnickee@nnickee.com>
Subject: Re: qw and delimiter usage
Message-Id: <E3A8678FB5B1AE99.2B819259E07EBFF9.0E978DC607354B5B@lp.airnews.net>

On Tue, 11 Jul 2000 14:55:05 GMT, someone claiming to be
gopal_bhat@my-deja.com said:

>	This serves the purpose of splitting (split()).. But I would like to
>get the following working:

>#!/usr/local/bin/perl
>chomp($i=<STDIN>);
>@words=qw/$i/;
>foreach $j (@words)
>{
>        print("\n $j \n");
>}

>	This fails because 'qw' construct uses '$i' itself as a element in the
>array instead of interpolating it.  Is there any way I can acheive this
>without using regular expressions or 'split'.
>	This is one of my perl class assignments. Any help will be appreciated.
>Thanks

Is using qw one of the requirements?
Or is the requirement simply to not use a regex or split?

If qw isn't a requirement... check out perlfunc

(I'm not going to spoonfeed you since it's an assignment -- if I did,
the Guru's would start throwing great big globs of yucky stuff at me
:)

Nnickee



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

Date: Tue, 11 Jul 2000 16:16:41 -0700
From: glchy <glchyNOglSPAM@cc21.com.sg.invalid>
Subject: Reloading config file under Apache::Registry
Message-Id: <21de0a40.9d80a514@usw-ex0104-031.remarq.com>

Hi,

Im (slowly!) porting my .pls and .pms under Apache::Registry. I
got a config file that is required by the .pls and .pms. I want
to be able to bring changes to my config file without restarting
the server and without using Apache::StatInc. Following the
suggestion on http:://perl.apache.org/guide/porting.html
("Reloading Configuration Files"), im using the following
subroutine to poll the config file's modification time before
the script is compiled.

use vars qw(%MODIFIED);
  sub reread_conf{
    my $file = shift;
    return unless $file;
    return unless -e $file and -r _;
    unless ($MODIFIED{$file} and $MODIFIED{$file} == -M _){
      my $result;
      unless ($result = do $file) {
        warn "couldn't parse $file: $@" if $@;
        warn "couldn't do $file: $!"    unless defined $result;
        warn "couldn't run $file"       unless         $result;
      }
      $MODIFIED{$file} =  -M _; # Update the MODIFICATION times
    }
  } # end of reread_conf

Instead of putting that subroutine in all my .pls and .pms, i
tried to put in a lib file which would be called by the .pls
and .pms. However, it seems that the lib file is loaded and put
in memory (as it is under a module dir under Apache::Registry).
Hence it works only for the first .pl or .pm which calls it.

Am i going the long-winded way by having a lib file containing
the sub reread_conf to check my 'real' conf file and
subsequently reload it if it has changed? I would have thought
tt it is quite easy!! Ive even tried to put a require lib file
in a apache startup perl file (*i think a startup file cannot
contain require()s*).

Converting the config file in a module is not an option as i
dont want to export all the variables and wouldnt want to change
the internals of the config file.

Help!  ....... and thanks!!!

GC.




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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Tue, 11 Jul 2000 18:06:46 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: running system command as root from perl
Message-Id: <brian-ya02408000R1107001806460001@news.panix.com>

In article <PhMa5.9$M53.2541706@news.interact.net.au>, "Troy Bell" <troyNO@SPAM.troysplace.net> posted:

> In article <brian-ya02408000R1007002308000001@news.panix.com>,
> brian@smithrenaud.com (brian d foy) wrote:

> > kill -USR1 `cat /etc/httpd.pid`

> Hrm, why go to all that trouble, when you can just run your apachectl
> script?

it does the same thing if you look under the hood :)  you could 
also use Perl's kill() if you like, but then your script has to
have permission to restart the server, which is not wise. allowing
a non-priveleged process control system resources is bad.  that's
why it is supposed to be non-priveleged ;)

> (Also, make sure this isn't visible to the outside world, eg. on an
> internal net, .htaccess'd etc. etc.)

i've heard this sentiment a lot lately - being in an internal network
is no protection from malicious intent.  it's not good to lower your
guard because you *think* you are safe.  it might be true in your
situation, but it's not something that you should recommend to other
people.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Tue, 11 Jul 2000 21:57:17 GMT
From: ynotssor@my-deja.com
Subject: Re: running system command as root from perl
Message-Id: <8kg57k$9u0$1@nnrp1.deja.com>

In article <8kfepr$ndb$1@nnrp1.deja.com>,
  kmhanser@my-deja.com wrote:

> Okay, now I've got a killhttpd file:
> -r-sr-x---    1 root     www            60 Jul 11 11:24 killhttpd
> which looks like this:
> #!/bin/sh
> kill -USR1 `cat /usr/local/apache/logs/httpd.pid`
> However, when I run this program as www, it tells me:
> kill: (2476) - Not owner
> If I run as root, it works (obviously).

The user that is running the system script must be gid www, not uid.
You'll want to know the gid of your cgi script execution that is making
the system call.

> In article <brian-ya02408000R1007002308000001@news.panix.com>,
>   brian@smithrenaud.com (brian d foy) wrote:
>> In article <8ke1rg$nf7$1@nnrp1.deja.com>, ynotssor@my-deja.com
>> posted:
: The killhttpd program is a trivial script:
: #!/bin/sh
: kill -HUP `ps -aef | grep httpd | grep -v grep | awk '{print $2}'`
>>
>> that won't work for many reasons, and it's just dumb.
 ...

A response to brian@smithrenaud.com:
My, thanks so much for telling me that. Our Java developers, each of
whom has a separate Apache server running on priveleged port 80 for
their testing purposes, have been using exactly that script for about a
half year now, which directly the child processes as well as the parent
PID.

This is the first I've heard about its inadequacy.

Suppose you enumerate at least a few of the "many reasons" that are
"dumb", and I'll be sure to rewrite the script so that they can continue
their work without all the failure that they've must have been
encountering, but failed to inform me of. (Look at me end my sentences
in a preposition!;)


-   tony


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 12 Jul 2000 08:59:08 -0500
From: "Troy Bell" <troyNO@SPAM.troysplace.net>
Subject: Re: running system command as root from perl
Message-Id: <WENa5.11$w53.2537605@news.interact.net.au>

In article <brian-ya02408000R1107001806460001@news.panix.com>,
brian@smithrenaud.com (brian d foy) wrote:

> i've heard this sentiment a lot lately - being in an internal network is
> no protection from malicious intent.  it's not good to lower your guard
> because you *think* you are safe.  it might be true in your situation,
> but it's not something that you should recommend to other people.

Thus the comment at the top:

"If you really want to create a security hazard (heh) install suid perl
and do the following:"

My suggestion was the Easy Way Out (tm) of how to overcome his prob.

I didn't say, or imply, that it was the most secure way of doing things,
because, quite frankly, it's probably the least secure way of doing it.

;-)

Depending on his setup, it might be all he needs.

Now, if he had of said in the top of his post:

"I'm extremely security anal and want to find the most secure way to do
this, whilst still being (l)user friendly", then I would have tossed a few
more ideas around. But, alas, he didn't. :( I'm quite happy to listen to
anyone elses comments on making this more secure actually, as I plan on
doing something like this myself.

Kind regards,
Troy.


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

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


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