[6472] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 97 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 00:07:37 1997

Date: Tue, 11 Mar 97 21:00:26 -0800
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, 11 Mar 1997     Volume: 8 Number: 97

Today's topics:
     an old script that suddenly stopped working :-) <young@mci.net>
     ANNOUNCE:  IO::Format 0.02 (perl formats, object orient <beck@qtp.ufl.edu>
     BLAT Help (Jeremy Coulter)
     Re: BLAT Help (Nathan V. Patwardhan)
     Re: can i pass a filehandle through a socket? <tchrist@mox.perl.com>
     Date conversion from server logs to time() format <webmaster@gmom.com>
     do_aspawn loses its way? (Howard Foster)
     Re: Field Separators <tchrist@mox.perl.com>
     Re: How to overwrite a file? (Tad McClellan)
     Re: Install help for 5.003 on Solaris? (Sajjad Lateef)
     Re: matching whitespace? (Brian L. Matthews)
     Re: operations with dates in PERL.... (Steffen Beyer)
     passwd entries - more info <dbenn@vision.net.au>
     password entries <dbenn@vision.net.au>
     Re: Perl on Windows 95 (Paul Downing)
     Re: RFC821Header Decoder (Kevin Johnson)
     Scripts to parse common server logs <webmaster@gmom.com>
     Re: Shadow passwords and perl <rootbeer@teleport.com>
     Signal catching with alarm <schramm@one.net>
     Re: So easy they do not explain pattern match. <wkuhn@uconect.net>
     Standard "Reaper" procedure doesn't work on Solaris. (Gideon King)
     Re: Transferring a socket descriptor <tchrist@mox.perl.com>
     Re: What's a good Perl book? (Tad McClellan)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Jettero Heller)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Jettero Heller)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Mar 1997 20:40:09 -0600
From: jeff young <young@mci.net>
Subject: an old script that suddenly stopped working :-)
Message-Id: <33261789.2679@mci.net>

i have one.  it's something i wrote a while ago and it's been doing
fine
ever since.  i'm hoping that someone here has experienced the same
problem
or something similar.

the script forks a secure shell (ssh) and does some configuration
on a dec alpha, restarts a process, etc....   i've tracked the problem
down to
the open2.pl library (i think) and am having trouble making any further
progress.
it appears that the script cannot complete the fork any more.  i am
pretty confident
that someone has upgraded my perl binary, but when i try to return to
the older
version 4.036-5.002, the script still fails.

a snippet of the code and some debug output are included below.  note
the
strange doings with the $kidped variable, first it's set, then it's
not.

this part of the script decides whether or not we're going to fork out
to ssh and
log onto the box, if so, it then opens the two filehandles
'fromsshscript' and
'tosshscript' to read from and write to the dec.  The script dies
(nongracefully) with
the first attempt to 'print(TOSSHSCRIPT...)' with the error:

'Debugger write on a pipe with no one to read it'

  if($diff||$load||$addroute){
          $nonzeropid=&open2(FROMSSHSCRIPT,TOSSHSCRIPT, "/homes/new/young/bin/slog $mrouters[$i] $passwd");
          &Count_to_Ten();
          if(!$nonzeropid){die "the pid you returned is zero"};
          print(TOSSHSCRIPT "\n");
          select(undef,undef,undef,0.5);
          print(TOSSHSCRIPT "ls\n");
          select(undef,undef,undef,0.5);
          while($xfoo=){
              while($xfoo){
                  print($xfoo); # for debugging
                  if(ord(chop($xfoo))==13){
                      last;
                  }
              }
              if($xfoo && $xfoo eq "# "){
                  last;
              }
          }
          $oldhandle = select(STDOUT);
          $|=0;
          select($oldhandle);
          print(STDOUT "logged into $mrouters[$i] successfully\r\n");
      }

This is the debug output, i printed $kidpid before the fork

(undefined), then after the fork (1654), then after the test

to be sure that kidpid exists (0).  i can't figure out why

$kidpid would be reset in open2.pl?

  creating config for xxxx.xxx
  main::(/fs/foghorn.bipp/bipp/bin/mrconf2:38):
  38:             $nonzeropid=&open2(FROMSSHSCRIPT,TOSSHSCRIPT, "/homes/new/young/bin/slog $mrouters[$i] $passwd");
    DB<2> s
  main::open2(/opt/GNUperl5/lib/open2.pl:23):
  23:         local($kidpid);

{some deletions for brevity, see open2.pl code)

  main::open2(/opt/GNUperl5/lib/open2.pl:40):
  40:         if (($kidpid = fork) < 0) {
    DB<2> print $kidpid

    DB<3> s
  main::open2(/opt/GNUperl5/lib/open2.pl:42):
  42:         } elsif ($kidpid == 0) {
    DB<3> main::open2(/opt/GNUperl5/lib/open2.pl:42):
  42:         } elsif ($kidpid == 0) {
    DB<3> print $kidpid
  1654
    DB<4> s
  main::open2(/opt/GNUperl5/lib/open2.pl:43):
  43:             close $dad_rdr; close $dad_wtr;
    DB<3> print $kidpid
  0
    DB<4> n
  main::open2(/opt/GNUperl5/lib/open2.pl:43):
  43:             close $dad_rdr; close $dad_wtr;
    DB<4>

jeff young
young@mci.net



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

Date: 11 Mar 1997 15:47:16 -0500
From: Sullivan Beck <beck@qtp.ufl.edu>
Subject: ANNOUNCE:  IO::Format 0.02 (perl formats, object oriented, footers)
Message-Id: <reh209mkvfu.fsf@qtp.ufl.edu>


This is to announce the availability of IO::Format 0.02.  This is still an
alpha release.  I have only used it in small, toy applications, so there
are probably bugs in it.  Still, it does seem to work well in the cases
I've tested it in, so others may find it useful, and at this point, I would
like to get some feedback about it.

IO::Format is a module for dealing with perl formats, much the way
IO::Handle deals with filehandles.  It is object oriented and has some
added functionality with respect to normal perl formats (the main one is
that it handles footers as well as headers).

The major problem is that it is impossible to use variables declared with
"my" in the format.

This module is not available from CPAN.  When it becomes a bit more mature,
I will submit it, but for now you can get it from my home page:
  http://www.qtp.ufl.edu/~beck

Sullivan



One question for perl wizards:

One thing I would like to do is to have the lexical variables (those
declared with "my") from the calling routine available in forming the
format.  The problem is that the format is actually formed by "eval"ing a
string (similar to the way described in the perlform manpage) in one of the
module routines.  Is there any way to gain access to the lexical variables
from the routine that directly called the module routine during the eval?
I am unfamilar with the capabilities of the XS extensions (even after
browsing the man pages).  Would they be able to do this?  If so, I'll learn
how to program them.  Any suggestions would be appreciated.



-----------------
The README file:
-----------------

Copyright (c) 1997 Sullivan Beck. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

Notes for version 0.02:
  Added footers.
  Added the formline command (though it is a bit different from standard perl).

  I haven't figured out how to make the stdout.t test work properly when
  called via "make test" yet, so I turned it off when called by "make test".
  It still works fine if you call it with the runtests script in the t
  directory.

  I have had minimal feedback on this module so far, so I suggest not using
  it for major operations.  Also, I don't guarantee backwards compatibility
  at this point.  I'm still making decisions about what exactly the interface
  should be.  If you want to have some say in the matter, nows the time.

  ############################################################################
  If you would like to stay informed about future versions of this module,
  and especially if you are interested in beta testing future versions,
  please let me know by email at:
    beck@qtp.ufl.edu

  The newest version (which should be considered a alpha version) is available
  through my home page:
    http://www.qtp.ufl.edu/~beck
  Feel free to try it out.

  This module is still in alpha.  As soon as a real release is available, I
  will announce it in comp.lang.perl.misc and comp.lang.perl.announce and
  submit it to CPAN.
  ############################################################################

Formats, like filehandles, were very difficult to work with when perl 5
initially came out, especially when it came to passing them in and out of
subroutines (and especially in and out of modules).  The FileHandle (and
later IO::Handle) module eliminated the problems associated with filehandles,
but the problem still existed with formats.  Hence, this module.  This module
add an object oriented interface to formats in the same way that IO::Handle
adds an interface to filehandles.

This module offers some functionality that normal perl formats do not offer
such as restricting pagebreaks in the middle of a formatted write and the
use of footers as well as headers.

If you work with formats a lot, this may come in handy.

This module is patterned after Graham Barr's IO:: routines (and requires them
to run).  My thanks to him for providing an excellent interface to perl IO.



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

Date: Wed, 12 Mar 1997 01:55:26 GMT
From: vss@xtra.co.nz (Jeremy Coulter)
Subject: BLAT Help
Message-Id: <33270ca2.8405446@202.37.101.7>

Hi. has anybody used BLAT via a perlscript ?

If so can they let me know, and even a wee demo would be good, so i
can see who to use it.

Also, I am running IMAIL Mail Server. Does BLAT send the message to
the Mail Server ?

I am not to clear on how it actually works..... 

Cheers Jeremy Coulter


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

Date: 12 Mar 1997 03:15:37 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: BLAT Help
Message-Id: <5g574p$fj5@fridge-nf0.shore.net>

Jeremy Coulter (vss@xtra.co.nz) wrote:

: Also, I am running IMAIL Mail Server. Does BLAT send the message to
: the Mail Server ?

BLAT talks to the smtp (mail) server, yes.  If I understand correctly,
you pass BLAT command-line arguments and redirect a file to it on STDIN,
which means that you need to write everything to a file, first, then mail
the file using BLAT (blech!).

This should be documented in the BLAT package.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 12 Mar 1997 02:59:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: can i pass a filehandle through a socket?
Message-Id: <5g567d$pi2$1@csnews.cs.colorado.edu>
Keywords: perl5 filehandle socket

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    felix@nytimes.com writes:
:i was just wondering if it's possible in perl5 to pass a filehandle,
:(in particular a filehandle that has been used by accept to attach to
:an incoming connection) - over another filehandle to a waiting process.
:
:i.e. if i wanted to create a server that upon startup shoots out 5
:or so kids which then do nothing. the server sits on a port recieves
:connect requests and hands them off to her waiting children.
:
:is something like that possible? thanks for any info/pointers.

It is possible on some operating systems.  You have to use 
send() with the access right field.  Look in the Stephen's book.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
*** The previous line contains the naughty word "$&".\n
                if /(ibm|apple|awk)/;      # :-)
            --Larry Wall in the perl man page


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

Date: Tue, 11 Mar 1997 21:04:34 -0500
From: Ross Carlson <webmaster@gmom.com>
Subject: Date conversion from server logs to time() format
Message-Id: <33260F32.7410@gmom.com>

Hello all,

I am trying to find some perl routines that will take the date format
found in the web server common log format, and convert it into the
integer format returned by time(). Can anyone point me in the right
direction?

Thanks in advance.

-- 
Ross A. Carlson
___________________________________

    Metacraft Internet Services
      webmaster@metacraft.com
     http://www.metacraft.com
      The Real Estate Guide:
      http://www.nehomes.com
___________________________________

Eat healthy, stay fit; die anyway.


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

Date: 12 Mar 1997 01:25:49 GMT
From: hfoster@euca.CS.Berkeley.EDU (Howard Foster)
Subject: do_aspawn loses its way?
Message-Id: <5g50mt$b1q@agate.berkeley.edu>

Hello all,

Is there an easy fix for the following?  Looks like that pp_sys.c
references vms (VMS?) code.

make[1]: Entering directory `/home/orodruin/h/bair/hfoster/perl-5.003'
cc   -o miniperl miniperlmain.o libperl.a -lsocket -lnsl -ldl -lm -lc -lcrypt 
Undefined                       first referenced
 symbol                             in file
do_aspawn                           libperl.a(pp_sys.o)
do_spawn                            libperl.a(pp_sys.o)
ld: fatal: Symbol referencing errors. No output written to miniperl
make[1]: *** [miniperl] Error 1

Sorry if this such an elementary q, but I (and a number
of others) have this problem.  Mine on a ...  `uname -a`
SunOS galaxy 5.5.1 Generic sun4u sparc SUNW,Ultra-Enterprise
(a very nice machine I might add but I've only had about
2 hours experience with it).

-Howard

Howard Foster, Ph.D., GIS-type guy
----------------------------------
UCB Digital Library Project -- Soda Hall:	510-642-8234
UCB Center for Environmental Design Research:	510-643-6307
-- 
Howard Foster, Ph.D., GIS type-guy
----------------------------------
Digital Library Project -- Soda Hall:		510-642-8234
Center for Environmental Design Research:	510-643-6307


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

Date: 12 Mar 1997 02:16:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Field Separators
Message-Id: <5g53m2$nq3$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    abw@peritas.com (Andy Wardley) writes:
:Because $\ is the output record seperator.  $/ is the input seperator,
:aliased to $INPUT_RECORD_SEPERATOR when you "use English;".

Um, no it's not.  It's aliased to $INPUT_RECORD_SEPARATOR in English,
and in English.  Remember the following mantra: "See pa rat, eeeeee!!!"
It's not Ma Rat, nor Baby Rat, but Pa Rat.

--tom

-- 
	Tom Christiansen	tchrist@jhereg.perl.com

if (shm == (char *)-1)  /* I hate System V IPC, I really do */
    --Larry Wall, from doio.c in the v5.0 perl distribution


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

Date: Tue, 11 Mar 1997 19:41:37 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to overwrite a file?
Message-Id: <hk15g5.851.ln@localhost>

Claudia Ma (maclaudi@cps.msu.edu) wrote:
: Hi,

: I'm working on a cgi right now: when someone fill a form online, the data
: are saved to a file. But the problem is when the same person wants to
: change the data, it can't be done.
                   ^^^^^^^^^^^^^^^^

What's that mean?

File not modified?

Modified but previous contents are gone?

Issues an error message?

 ...



: I use :

: $dir = "/mydir";
: $file = "myfile";

: open (DATAFILE, "> $dir/$file");

That will wipe out the current contents of the file ya know.

You may want to read the data from the file first, if you want 
to keep it.


: Can someone one tell me why?
      ^^^^^^^

Perl might. If you ask it to ;-)

open (DATAFILE, "> $dir/$file") || die "could not open '$dir/$file'  $!";



check return values, check return values, check return values...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 12 Mar 1997 02:04:53 GMT
From: sajjad@icarus.cc.uic.edu (Sajjad Lateef)
Subject: Re: Install help for 5.003 on Solaris?
Message-Id: <5g5305$1nts@piglet.cc.uic.edu>

: > Briefly, Configure makes a list of *hundreds* of signal names, and
: > that causes problems later in the script. 
: Jim, what kind of problems are you getting? My Configure script exits
: with a Shell syntax error and I'm wondering if it's the same problem.

	Hmm .. that means that I am not the only one. <whew> 	

My system: Pentium running Solaris 2.5 for x86
uname -a ->  SunOS eworks 5.5 Generic i86pc i386 i86pc i86pc

compiler: gcc 2.7.2 (I have run fixincludes so have correct header files)

I do not have /usr/ucb in path. I am using Sun's awk. I got the perl source
from sunsite.unc.edu. (perl 5.003)

Only giving "-lm -lsocket -lnsl" options to compiler as per
perl archive notes on compiling perl on Solaris. 

Configure does the following: (starting around line 7963)
	a: Prepares a list of signal names from signal.h
	(really complex use of grep/awk/sed/sh and variable names like xx
	and xxx and xxxfiles)
	b: Uses this list to prepare c code called signal.c 
	(this works fine. I got signal.c by commenting out the code that
	removes it later)   
	c: Generates an awk script file called signal.awk 
	d: Creates a sh script file called signal_cmd
	e: Runs signal_cmd. This does the following
		e1: that compiles signal.c 
		e2: then runs the resulting executable,
		e3: passes its output to the awk script signal.awk
		e4: and generates a file called signal.lst

		if the above does not work, signal_cmd does 
		e5: Guesses the values of SIGNALs using kill -l
		and generates signal.lst 

	f: Generates the values for the two variables sig_name and sig_num
	from signal.lst that are then stored in config.h lines 1531 and 1532.
		f1: It also prints the values of the signals from $sig_name
	These variables contain 4000+ SIGNAL Names and Numbers each. 

	Here: awk barfs saying something like "input line too long"
and the rest of Configure work on.

The problem is in signal.awk. The END block has some code that is broken.

It produces a list of 4096 Signal Numbers in the following format:
---------------------extracted from signal.lst -----------------------
HUP 1
INT 2
QUIT 3
ILL 4
 ... <snip>
THAW 35
CANCEL 36
RTMIN 37
NUM38 38
NUM39 39
NUM40 40
 ... <snip approx 4000 lines)
NUM4094 4094
NUM4095 4095
PAUSE 4096
IOT 6
CLD 18
POLL 22

-------------- signal.awk from perl 5.003 Configure script -------------
BEGIN { ndups = 0 }
$1 ~ /^NSIG$/ { nsig = $2 }
($1 !~ /^NSIG$/) && (NF == 2) {
    if ($2 > maxsig) { maxsig = $2 }
    if (sig_name[$2]) {
        dup_name[ndups] = $1
        dup_num[ndups] = $2
        ndups++
    }
    else {
        sig_name[$2] = $1
        sig_num[$2] = $2
    }

}
END {
    if (nsig == 0) { nsig = maxsig + 1 }
        for (n = 1; n < nsig; n++) {
                if (sig_name[n]) {
                        printf("%s %d\n", sig_name[n], sig_num[n])
                }
                else {
                        printf("NUM%d %d\n", n, n)
                }
        }
    for (n = 0; n < ndups; n++) {
                printf("%s %d\n", dup_name[n], dup_num[n])
    }
}
----------- end signal.awk -----------------------------------

	Any awk hackers out there want to make sense of this?
All I want to do is get perl 5.003 to compile.

    Please email me or post here. I am willing to summarize responses
and post here. Thanks in advance.

thanks,
Sajjad  
--
Sajjad Lateef			http://www.eecs.uic.edu/~slateef/		
sajjad@acm.org


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

Date: 11 Mar 1997 19:03:21 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: matching whitespace?
Message-Id: <5g56dp$qc$1@halcyon.com>

In article <5g4itd$4hd@agate.berkeley.edu>,
alex filippenko <astroweb@astron> wrote:
|i know i could look it up but i am 20min away from any perl book....sorry

If you're somewhere you can do perl, you should be somewhere you can
read the perl pods. They should be installed locally (yell at your
admin if they're not), but if not, they're available at various places
and in various formats on the web. Start at
<http://www.perl.com/perl/info/documentation.html#online> and follow the
links from they're and read perlre.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 11 Mar 1997 22:50:33 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: operations with dates in PERL....
Message-Id: <5g4njp$bte$1@en1.engelschall.com>

Gustavo Espinosa Tavitas <gespinos@nic.mx> wrote:
> Hi!
> I have this petite question:
> *I have a date field of the form 'YYYY MMM DD' and I need to
> add 30, 90, XX days to it. I get this date from the array that
> localtime(time) returns.
[...]
> and i just have to add the equivalent of XX days in seconds,right?
> Wrong!!! timelocal just don't gives me anything i expect.
> Can anyone explain me how can i make this work ...?
> I'd Appreciate it.
> Thanks.

This task can be accomplished in a much simpler way if you're using the
Date::DateCalc module.

There you can say

  ($year,$mm,$dd) = calc_new_date($year,$mm,$dd,$offset);

where $offset is any offset (positive or negative) in days you like.

In the Date::DateCalcLib module (contained in the same distribution)
there is also a function to apply year, month and day offsets at the
same time.

And there is even a function in the Date::DateCalc module that lets
you calculate new dates with day/time offsets.

You can find the latest version on CPAN (see "The Perl 5 Module List"
in news:comp.lang.perl.modules for a list of CPAN ftp servers) or on
the authors (that's me, btw :-) ) web site

http://www.engelschall.com/u/sb/download/

Espero mucho que eso le ayude bastante!

Avec l'expression de mes sentiments distingues,
-- 
    |s  |d &|m  |    Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
    |   |   |   |    software design & management GmbH & Co. KG
    |   |   |   |    Thomas-Dehler-Str. 27, 81737 Munich, Germany.
                     "There is enough for the need of everyone in this world,
                     but not for the greed of everyone." - Mahatma Gandhi


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

Date: 12 Mar 1997 03:32:48 GMT
From: "David Benn" <dbenn@vision.net.au>
Subject: passwd entries - more info
Message-Id: <01bc2f5f$ba495d20$82f411cb@vis1.hq.vision.net.au>

I should clarify my last post.

Using getpwent() I _can_ read the master password file under BSDi but the
password expiry ("change") field does not show up in each entry, nor does
the account expiry
field. It's the "change" field that I'm interested in.

Regards,

David Benn


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

Date: 12 Mar 1997 03:17:57 GMT
From: "David Benn" <dbenn@vision.net.au>
Subject: password entries
Message-Id: <01bc2f5d$a7033300$82f411cb@vis1.hq.vision.net.au>

Apart from reading the master password file directly, are there functions
such as
getpwent() which will read the master password file rather than the
world-readable
password file? If not, I'll just do the former. I'm running BSDi BTW.

Rgds,

David Benn


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

Date: Wed, 12 Mar 1997 04:32:48 GMT
From: enc@pobox.com (Paul Downing)
Subject: Re: Perl on Windows 95
Message-Id: <33263178.1679075@207.126.101.80>

On Mon, 24 Feb 1997 12:57:06 -0500, Peter Holtan <puzzled@cris.com>
wrote:

>Hank,
>
>I have the same question as Mark did.  Please excuse me if my question
>sounds stupid, but I am very new to this.  Where can I get a server? Is
>there a good one that you would suggest that I could download for free? 
>I hope I could get a server for Windows95, I have LINUX but I have too
>many problems with it and X runs so damn slow.
>

If you are running the new version of Win 95, the OSR2, it has a
Personal Web Server that runs as a network service.

As far as Linux and X goes, it got either a very slow machine or it is
configured wrong. I have used X on a 386DX/20 with 8MB of RAM with no
problem. Check your settings and take that gripe to the comp.linux
groups. :-)


Paul Downing
------------------------------------------------------------
Enterprise Network Consulting / owner	
Baker, Louisiana			
E-mail: enc@pobox.com   
-------------------------------------------------------------  


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

Date: 11 Mar 1997 19:15:02 -0700
From: kjj@primenet.com (Kevin Johnson)
Subject: Re: RFC821Header Decoder
Message-Id: <5g53j6$9gf@nnrp1.news.primenet.com>

On Tue, 11 Mar 1997 03:06:00 -0600, Sun Tong <tsun@fs.com> wrote:
>I am a newbie to perl. I want to begin my first perl program with this
>"RFC821Header Decoder". Program desciption followed.

It would probably be more precise to say that you are interested in
an rfc822 message parser.

>I don't have a copy of module list, and don't know if it has been
>implemented. Will you please kindly help me with it?

You are in luck.  One has already been written.
(assuming you consider yourself lucky for not having to reinvent the wheel :-)

Check out the MailTools module in CPAN at:
	http://www.perl.com/CPAN/modules/by-module/Mail/

-- 
thx,
kjj@pobox.com   http://www.pobox.com/~kjj/


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

Date: Tue, 11 Mar 1997 21:03:32 -0500
From: Ross Carlson <webmaster@gmom.com>
Subject: Scripts to parse common server logs
Message-Id: <33260EF4.1FCE@gmom.com>

Hello,

I am looking for premade scripts that can be used to parse web server
logs in the common log format. I browsed CPAN, but only found the libwww
modules which don't seem to be what I need.

I also am looking for date conversion routines that might be able to
take the dates from the common log format, and convert them into the
integer format that is returned from time().

Anyway, if anyone can point me in the right direction, it would be
greatly appreciated.

Thank you!

-- 
Ross A. Carlson
___________________________________

    Metacraft Internet Services
      webmaster@metacraft.com
     http://www.metacraft.com
      The Real Estate Guide:
      http://www.nehomes.com
___________________________________

Eat healthy, stay fit; die anyway.


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

Date: Tue, 11 Mar 1997 19:50:32 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Trevor Clout <tc@space.net.au>
Subject: Re: Shadow passwords and perl
Message-Id: <Pine.GSO.3.96.970311192859.7340E-100000@kelly.teleport.com>

On 11 Mar 1997, Trevor Clout wrote:

> The perl function getpwuid is meant to return with an encrypted password
> from the /etc/passwd file. 

That's a common misconception. :-)

> In a shadow password system this entry in the /etc/passwd file is just a
> * and the real encrypted password is stored in the /etc/shadow file.
> Does anybody know how to make perl deliver the correct entry under
> shadow.

Actually, if shadow passwords are correctly installed, or if NIS or
something similar is, the getpwuid function should track down and return
the information requested. Except for the password, if that's shadowed.
(And what is the point of having shadowed passwords if anybody could read
the hidden passwords? :-)

All is not lost. On some systems, you may still _validate_ an encrypted
password, even though you can't see what the encrypted form is. In this
case, the returned ("crypted") password may look like "##username". You
simply feed that to crypt, and use this test. Magically, this test works
the same on systems which _don't_ have shadow passwords. Cool, huh? (Alas,
I no longer have access to a system which offers this feature, so this
code is from memory.)

    # Testing $attempt for user $username
    $crypted = (getpwnam($username))[1];
    $valid_password = (crypt($attempt, $crypted) eq $crypted);
    if ($valid_password) {
        print "Yep, it's really you!\n";
    } else {
        print "Intruder Alert! Intruder Alert!\n";
    }

So, that didn't work for you? Well, on some systems, the hidden password
can be returned by getpwnam - but you gotta be root to see it. This is as
it should be; you don't want non-root users to be able to get at the
passwords!

Okay, now you're probably thinking that that solution is useless. Well,
maybe it's not _totally_ useless. If nothing else, you can write a
password authenticating daemon which will run as root. To validate a
password, you would use methods from perlipc to talk to the daemon and
hear what it says. 

Hey, I never said it would be easy! :-)

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 12 Mar 1997 03:53:56 GMT
From: "Rich Schramm" <schramm@one.net>
Subject: Signal catching with alarm
Message-Id: <01bc2e99$7d00a700$1fc270ce@ras_schramm.scripps.com>

Hi,

I am writing a script that measures the elapsed time of retrieving a given
URL. The condition I am actually testing for will be when a URL does not
come back in a reasonable period of time.  Therefore, I need to make the
program work so that after a given number of seconds, the "get" will abort
and return an exit code to indicate the problem.  

Enter the alarm function. I am running alarm (twice actually to print the
return code to verify that the alarm is actually being set), but after the
given period of time, nothing happens.  It appears that my signal catching
code is not functioning.  I have used signal catching before with the CHLD
sig, during fork operations with expected results.  Similar code used for
the ALRM sig seems to have no effect.

The chunks that don't seem to work are:

$SIG{'ALRM'} = 'exitone';
sub exitone {
# Took longer than maxsecs to return,
# so exit 1
print "Times Up!\n";
exit(1);
}

alarm(5);

If anyone can tell me what is up with this, I would appreciate it.  The
script that is failing (the alarm part anyway) is below.

Thanks,

Rich

#!/usr/local/bin/perl
#
##############################################################
# Connects to the URL, downloads the src and return number of
# seconds it took to get the URL.
##############################################################
$url = $ARGV[0];
$maxsec = $ARGV[1];

$SIG{'ALRM'} = 'exitone';
# If you receive the ALRM signal, go to the
# exitone subroutine

$SIG{'CHLD'} = 'do_wait';
# If you receive the child signal, go to the
# do_wait subroutine

if ($url eq '' || $maxsec == '') {
 die "Usage: $0 [http|ftp]://servername/url maxseconds\n";
}

$pid = fork;

if ($pid == 0) {

  # this is the child process

  $start_time=time;
  $test=alarm 5;
  print "$test\n";
  $test=alarm 5;
  print "$test\n";
  # to make sure signal is really started.

  # Create a user agent object
  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("TimeChecker/0.9");

  # Create request 
  my $req = new HTTP::Request GET => "$url";

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  if ($res->is_success) {
  $srvresp = $res->content;
  } else {
  exit(2);
  }
 
  sleep 10; # for testing signal
  $stop_time=time;
  #print "Stop: $stop_time\n";
  $elapsed=$stop_time - $start_time;

  # Print the elapsed time;
  print "$elapsed\n";
  exit(0);
}

$SIG{'CHLD'} = 'DEFAULT';
while ( $kids != -1 ) {
  $kids=wait;
}

######################
# Subroutines
######################

sub exitone {
# Took longer than maxsecs to return,
# so exit 1
print "Times Up!\n";
exit(1);
}

sub do_wait {
 $pid=wait;
}




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

Date: Tue, 11 Mar 1997 19:14:28 -0500
From: Bill Kuhn <wkuhn@uconect.net>
Subject: Re: So easy they do not explain pattern match.
Message-Id: <3325F564.2070C5F9@uconect.net>

Unix utilities like grep, sed, and awk use regular expressions.  There
is no standard regular expression syntax for within or among these
utilities.  In other words, not only may grep have a different syntax
than sed, but grep on one unix system may be different than grep on
another unix system.  Pretty screwy, huh?

Perl has yet another flavor of regular expressions that combine elements
of grep, sed, and awk regular expressions.

For further reading I suggest the O'Reilly book entitled "Mastering
Regular Expressions" written by a "regular" in this newsgroup, Jeffrey
Friedl.  This book discusses the differences among the different
utilities with respect to regular expression engines and syntax they
use.  It is an invaluable reference!  There is an entire chapter/section
on perl regular expressions.

-Bill

-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 12 Mar 1997 02:34:41 GMT
From: gideon@csarc.otago.ac.nz (Gideon King)
Subject: Standard "Reaper" procedure doesn't work on Solaris.
Message-Id: <5g54o1$1s6$1@celebrian.otago.ac.nz>
Keywords: fork, reaper, ipc

I am using the standard "reaper" from the perlipc documentation to clean  
up child processes, and I find that it doesn't work under Solaris. The  
test can be reproduced using the standard code from the perlipc page. My  
test platforms have been:
NeXTXTEP 3.3, Perl 5.002 - Works
OpenStep 4.1, Perl 5.002 - Works
Solaris, Perl 5.002 - doesn't work
Solaris, Perl 5.003 - doesn't work

The offending code is:
sub REAPER 
{ 
	$SIG{CHLD} = \&REAPER;  # loathe sysV
	$waitedpid = wait;
	logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
}
$SIG{CHLD} = \&REAPER;

The observed behaviour is:
First time it's called, it works, but the server reports two "reaped"  
messages, the second one having a pid of -1.
The second time, the client thinks it has connected, but the server  
doesn't register anything, and the client reports "uninitialized value"  
for anything that should be returned from the server.
Third time, it works.
Fourth time, it doesn't, etc.

If I comment out the line
	$SIG{CHLD} = \&REAPER;  # loathe sysV
It doesn't give me the extra reaped message, but still doesn't work  
properly.

If I comment it all out, it always works, but I get zombie processes lying  
around.

Does anyone have any suggestions about how to solve this problem?

Thanks.

---

Gideon King                    | Phone +64-3-479 9017
Acting Manager                 | Fax   +64-3-479 8529
The Black Albatross            |
University of Otago            |
Computer Science Applied       | e-mail gideon@csarc.otago.ac.nz
         Research Centre       | NeXT mail, MIME ok. PGP key available.
Department of Computer Science |
P.O. Box 56                    | I don't have a solution
Dunedin                        |         but I admire the problem.   
New Zealand                    |
WWW access: http://www.csarc.otago.ac.nz:805/


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

Date: 12 Mar 1997 04:34:37 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Transferring a socket descriptor
Message-Id: <5g5bot$1e2$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Bradley.Clark@disclosure.com writes:
:I have encountered a problem while trying to pass the
:socket descriptor to an unrelated client process.  I'm trying to
:use a domain-socket to transfer a socket descriptor.  In
:C this can be done with sendmsg and recvmsg are their any
:equivalent perl functions.  If not, any other ideas for passing
:socket descriptors to an unrelated client process using sockets
:are more than welcome.

There's no reason it can't be done in Perl if it can be done
in C, but I haven't seen the code to do it, nor had sufficient
incentive to write it up myself.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "Sometimes I wish I could put an expiration date on my quotes." --Larry Wall


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

Date: Tue, 11 Mar 1997 19:37:15 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What's a good Perl book?
Message-Id: <bc15g5.851.ln@localhost>

David Tong (dtong@lynx.dac.neu.edu) wrote:
: Hi,

: I know C and KSH very well but I am new to Perl. I need to implement on NT,
: UNIX and QNX with Perl. What would be a good Perl reference book I can get
: in the book store?

Tutorial:

"Learning Perl" by Randal Schwartz


Reference:

"Programming Perl" by Larry Wall, Tom Christiansen and Randal Schwartz



both available from:

http://www.ora.com


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 12 Mar 1997 03:21:02 GMT
From: heller@nacs.net (Jettero Heller)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g57eu$283@tracy.nacs.net>

John Lockwood (johnl@calweb.com) wrote:
: "Terje A. Bergesen" <terjeber@eunet.spm-protect.no> wrote:
: 
: >> Unix appeals more to me and is more advanced technically, but I am
: >> afraid that it is losing the market share to Windows 95.
: 
: Unix is more advanced technically?  That's interesting.  The last time
: I installed a modem on Windows NT the OS found it for me.  The last
: time I tried it on Unix I read about the nine files one had to edit,
: then gave up.   It seems to me that Unix is losing market share
: precisely because end users never make the programmer's mistake of
: confusing technical advancement with obtuseness.

*IF* it is loosing market share it's because the end user is
mistaking "brain dead simple" for "technical advancement". By your
logic the automatic transmission Cavalier is more technically
advanced than a manual Porsche or Ferrari, after all you have to
clutch and shift to get it to move. Do you still stand by your claim?

** Heller

-- 
                     http://www.nacs.net/cgi-bin/heller/jokes              
                        http://www.nacs.net/~heller/
'...and let there be light!' <FLICK> And there was light.
Van Roy's Law: An unbreakable toy is useful for breaking other toys.


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

Date: 12 Mar 1997 03:37:32 GMT
From: heller@nacs.net (Jettero Heller)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g58ds$283@tracy.nacs.net>

Tim Smith (tzs@halcyon.com) wrote:
: In article <5g1okc$n5e@asgard.actrix.gen.nz>,
: John Bickers <jjbicker@atlantis.actrix.gen.nz> wrote:
: >In article <5g0s9b$ld@sf18.dseg.ti.com>, Harold Stevens <wyrd@ti.com> wrote:
: >
: >> Thank you for injecting some sanity in an inane thread. I've been in the
: >> business 25 years and seen language/OS fads come and go with abandon. It
: >
: >    Is this a record for both left and right text alignment without
: >    inserted spaces or artificial filling?
: 
: No.  In fact, it is not very hard to make both the left and right
     [snip of a rather impress justification feat]
: that to be cheating, or at least inelegant.

It doesn't compare to William Evans' extremely wonderful
justification masterpiece on rec.humor on 16/Dec/1996. 
Find it at:
http://xp5.dejanews.com/getdoc.xp?recnum=3746906&server=dnserver.db96q5

** Heller

-- 
                     http://www.nacs.net/cgi-bin/heller/jokes              
                        http://www.nacs.net/~heller/
'...and let there be light!' <FLICK> And there was light.
Van Roy's Law: An unbreakable toy is useful for breaking other toys.


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

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

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