[29591] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 835 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 10 03:09:39 2007

Date: Mon, 10 Sep 2007 00:09:03 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 10 Sep 2007     Volume: 11 Number: 835

Today's topics:
        new CPAN modules on Mon Sep 10 2007 (Randal Schwartz)
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: Switching with case in perl ? <ben@morrow.me.uk>
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: Switching with case in perl ? <anno4000@radom.zrz.tu-berlin.de>
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: Switching with case in perl ? <joe@inwap.com>
    Re: Switching with case in perl ? <rkb@i.frys.com>
    Re: What is required for perl scripts to run correct wh  deanjones7@gmail.com
    Re: What is required for perl scripts to run correct wh  deanjones7@gmail.com
    Re: What is required for perl scripts to run correct wh  deanjones7@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 10 Sep 2007 04:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Sep 10 2007
Message-Id: <Jo4yED.11L1@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Bundle-Perl6-0.08
http://search.cpan.org/~marcel/Bundle-Perl6-0.08/
A bundle to install Perl6-related modules 
----
Constant-Runtime-0.01
http://search.cpan.org/~berle/Constant-Runtime-0.01/
Generates constants at runtime 
----
Data-Inherited-1.02
http://search.cpan.org/~marcel/Data-Inherited-1.02/
hierarchy-wide accumulation of list and hash results 
----
DateTime-Locale-0.35
http://search.cpan.org/~drolsky/DateTime-Locale-0.35/
Localization support for DateTime.pm 
----
DateTime-TimeZone-SystemV-0.002
http://search.cpan.org/~zefram/DateTime-TimeZone-SystemV-0.002/
System V and POSIX timezone strings 
----
Devel-PerlySense-0.01_13
http://search.cpan.org/~johanl/Devel-PerlySense-0.01_13/
IntelliSense for Perl 
----
Devel-PerlySense-0.01_14
http://search.cpan.org/~johanl/Devel-PerlySense-0.01_14/
IntelliSense for Perl 
----
Devel-PerlySense-0.01_15
http://search.cpan.org/~johanl/Devel-PerlySense-0.01_15/
IntelliSense for Perl 
----
ExtUtils-Install-1.44
http://search.cpan.org/~mschwern/ExtUtils-Install-1.44/
install files from here to there 
----
GRID-Machine-0.078
http://search.cpan.org/~casiano/GRID-Machine-0.078/
Remote Procedure Calls over a SSH link 
----
Getopt-Attribute-1.42
http://search.cpan.org/~marcel/Getopt-Attribute-1.42/
Attribute wrapper for Getopt::Long 
----
Graph-Easy-0.58
http://search.cpan.org/~tels/Graph-Easy-0.58/
Render graphs as ASCII, HTML, SVG or via Graphviz 
----
Graph-Easy-Manual-0.40
http://search.cpan.org/~tels/Graph-Easy-Manual-0.40/
HTML manual for Graph::Easy 
----
HTML-Menu-TreeView-0.8.1
http://search.cpan.org/~lze/HTML-Menu-TreeView-0.8.1/
----
Image-Info-1.26
http://search.cpan.org/~tels/Image-Info-1.26/
Extract meta information from image files (DEPRECATED) 
----
JE-0.017
http://search.cpan.org/~sprout/JE-0.017/
Pure-Perl ECMAScript (JavaScript) Engine 
----
MRO-Compat-0.05
http://search.cpan.org/~blblack/MRO-Compat-0.05/
mro::* interface compatibility for Perls < 5.9.5 
----
Mail-Summary-Tools-0.06
http://search.cpan.org/~nuffin/Mail-Summary-Tools-0.06/
Tools for mailing list summarization. 
----
Mango-0.01000_06
http://search.cpan.org/~claco/Mango-0.01000_06/
An ecommerce solution using Catalyst, Handel and DBIx::Class 
----
Metaweb-0.03
http://search.cpan.org/~skud/Metaweb-0.03/
Perl interface to the Metaweb/Freebase API 
----
Metaweb-0.04
http://search.cpan.org/~skud/Metaweb-0.04/
Perl interface to the Metaweb/Freebase API 
----
Metaweb-0.05
http://search.cpan.org/~skud/Metaweb-0.05/
Perl interface to the Metaweb/Freebase API 
----
Mobile-P2kMoto-0.02
http://search.cpan.org/~mbarbon/Mobile-P2kMoto-0.02/
interface with Motorola P2K phones 
----
Net-DSML-0.003
http://search.cpan.org/~charden/Net-DSML-0.003/
A perl module that supplies methods for connecting to a LDAP Directory Services Markup Language (DSML) server. 
----
Net-FTP-Throttle-0.32
http://search.cpan.org/~lbrocard/Net-FTP-Throttle-0.32/
Throttle FTP connections 
----
Net-Jabber-Bot-1.1
http://search.cpan.org/~toddr/Net-Jabber-Bot-1.1/
Automated Bot creation with safeties 
----
Net-OpenID-Server-0.13
http://search.cpan.org/~bradfitz/Net-OpenID-Server-0.13/
library for building your own OpenID server 
----
Ogre-0.26
http://search.cpan.org/~slanning/Ogre-0.26/
Perl binding for the OGRE C++ graphics library 
----
Set-IntSpan-1.12
http://search.cpan.org/~swmcd/Set-IntSpan-1.12/
Manages sets of integers 
----
Sphinx-Search-0.03
http://search.cpan.org/~jjschutz/Sphinx-Search-0.03/
Sphinx search engine API Perl client 
----
Sphinx-Search-0.04
http://search.cpan.org/~jjschutz/Sphinx-Search-0.04/
Sphinx search engine API Perl client 
----
Template-Provider-PAR-0.1.102
http://search.cpan.org/~npw/Template-Provider-PAR-0.1.102/
Include templates from a path within a PAR or Zip archive. 
----
Tie-RefHash-Weak-0.05
http://search.cpan.org/~nuffin/Tie-RefHash-Weak-0.05/
A Tie::RefHash subclass with weakened references in the keys. 
----
Tie-UnionHash-0.01
http://search.cpan.org/~zag/Tie-UnionHash-0.01/
Union hashes. Make changes to the last hash in arguments ( depend on option <freeze_keys>). 
----
Tk-RotatingGauge-0.21
http://search.cpan.org/~jquelin/Tk-RotatingGauge-0.21/
a rotating gauge for Tk 
----
Tk-RotatingGauge-0.22
http://search.cpan.org/~jquelin/Tk-RotatingGauge-0.22/
a rotating gauge for Tk 
----
Tk-Wizard-2.112
http://search.cpan.org/~mthurn/Tk-Wizard-2.112/
GUI for step-by-step interactive logical process 
----
W3C-LogValidator-1.2
http://search.cpan.org/~oliviert/W3C-LogValidator-1.2/
The W3C Log Validator - Quality-focused Web Server log processing engine 
----
XML-LibXML-1.64
http://search.cpan.org/~pajas/XML-LibXML-1.64/
Perl Binding for libxml2 
----
XML-LibXSLT-1.63
http://search.cpan.org/~pajas/XML-LibXSLT-1.63/
Interface to the gnome libxslt library 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sun, 09 Sep 2007 15:24:19 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189376659.373954.221160@19g2000hsx.googlegroups.com>

On Sep 9, 8:04 pm, lerameur <leram...@yahoo.com> wrote:
> On Sep 9, 7:56 pm, Paul Lalli <mri...@gmail.com> wrote:
>
> > On Sep 9, 11:38 am,lerameur<leram...@yahoo.com> wrote:
>
> > > Paul I used your glob function, I think this is sweet function.
> > > I tried using it with no success, I modified a little bit and still no
> > > success. Basically it is not creating the output file, and gives me an
> > > error when I try closing the file I am using to read.
>
> > You are *still* not checking open for errors, you are *still* not
> > including $! in the error message for the close.
>
> > If you refuse to askPerlfor help, why should any actual human beings
> > continue to help you?
>
> > Paul Lalli
>
>  I added them for the close and missed one for the open.
> i added  -or die "Could not open file: $!"; -
>
> I am not getting any error on opening files though.
>
> k

HI,

the loop is working but keeps on looping, Once the outer loop finds
the file, it gets the logs to the output file and keep repeating
extracting from the same log file. had to do a control C cause the
output file is growing huge.
k



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

Date: Mon, 10 Sep 2007 00:39:20 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Switching with case in perl ?
Message-Id: <8qcer4-s23.ln1@osiris.mauzo.dyndns.org>


Quoth Ron Bergin <rkb@i.frys.com>:
> It doesn't appear that you're using the strict or warnings pragmas.
> It would help if you ask Perl why it can't open the Loog_rr.txt file.
> It would also be better to put that open call prior to the glob.
> You also need to make your code easier to read/maintain by reducing
> the amount of indentation.
> 
> open(my $out_file, '>>', 'Loog_rr.txt') or die "Can't open Loog_rr.txt
> $!";
> 
> while (my $filename = glob("*$year$month$day$hours$minute*") ){
>    open($wordlisting1, '<', $filename) or die "Could not open
> wordlisting: $!";
>    while (my $line = <$wordlisting1> ) {
>       if ($line =~ m/beth/) {
>          @items =  (split(",",$line))[0..3];

You mention strictures above, but @items is not declared anywhere.

Except for the very special case of ' ', the first argument to split is
a regex. You should write it as a regex so people don't misread it:

    my @items = ( split( /,/, $line ) )[0..3];

>          print $out_file join(',', @items) , ";\n";

This can be made cleaner by using Perl's print-control variables: put

    local ($,, $\) = (',', ';\n');

at the top of the loop and then simply

    print $out_file @items;

>       }
>    }
>    close($wordlisting1) || die "couldn't close wordlisting: $!";

You want to be consistent about whether you use || or 'or' to check for
errors. Personally I'd always use 'or'; but then I'd always omit the
parens on open as well.

There's little point in checking for errors on close if you haven't
checked for errors as you read. What errors could occur at this point
that you care about?

> }
> close $out_file or die "Can't close out_file $!";

Again, the point of checking for errors when you close a file you were
writing to is to ensure all the data got written successfully: if you
care, you should be checking print succeeded as well.

Ben



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

Date: Sun, 09 Sep 2007 16:58:31 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189382311.122947.165650@o80g2000hse.googlegroups.com>

Hi,
I found the problem but have not been able to fix it.
th e output is good, but prints twice
I have two loop, with each its own increment. The while loop with the
glob function just hangs. I use an increment in that loop for minute2,
but minute2 also get incremented by the outer loop: Is there some sort
of exit I get put in my inner loop.
Also I tried using this:
my $filename = glob("*$year2$month2$day2$hours2$minute2*") ;
but I had so many errors I did not bother.

here is the program. I think this is more of logic question.:

for my $minute2 (0..59) {
my $logtime = strftime("%y%m%d%H%M", 0, $minute2, $hours2, $day2,
$month2 -1, $year2 + 100). "\n" ;
   #open each traffic log files and append them to one files

open(my $out_file, '>>', '$logtime$timestamp.txt') or die "Can't open
Log.txt$!";

while (my $filename = glob("*$year2$month2$day2$hours2$minute2*") ){

   open($wordlisting1, '<', $filename) or die "Could not open
wordlisting: $!";
   while (my $line = <$wordlisting1> ) {
      if ($line =~ m/beth/) {
         my @items =  (split(/,/,$line))[4,10,15,86];
			 print $out_file join(',', @items).  "\n";
							}
										}  	print $minute2;
	close($wordlisting1) or die "couldn't close wordlisting: $!";
		}
close $out_file or die "Can't close out_file $!";
 }#closing  for my minute loop



k



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

Date: Sun, 09 Sep 2007 17:24:12 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189383852.989424.14520@g4g2000hsf.googlegroups.com>

On Sep 10, 2:58 am, lerameur <leram...@yahoo.com> wrote:
> Hi,
> I found the problem but have not been able to fix it.
> th e output is good, but prints twice
> I have two loop, with each its own increment. The while loop with the
> glob function just hangs. I use an increment in that loop for minute2,
> but minute2 also get incremented by the outer loop: Is there some sort
> of exit I get put in my inner loop.
> Also I tried using this:
> my $filename = glob("*$year2$month2$day2$hours2$minute2*") ;
> but I had so many errors I did not bother.
>
> here is the program. I think this is more of logic question.:
>
> for my $minute2 (0..59) {
> my $logtime = strftime("%y%m%d%H%M", 0, $minute2, $hours2, $day2,
> $month2 -1, $year2 + 100). "\n" ;
>    #open each traffic log files and append them to one files
>
> open(my $out_file, '>>', '$logtime$timestamp.txt') or die "Can't open
> Log.txt$!";
>
> while (my $filename = glob("*$year2$month2$day2$hours2$minute2*") ){
>
>    open($wordlisting1, '<', $filename) or die "Could not open
> wordlisting: $!";
>    while (my $line = <$wordlisting1> ) {
>       if ($line =~ m/beth/) {
>          my @items =  (split(/,/,$line))[4,10,15,86];
>                          print $out_file join(',', @items).  "\n";
>                                                         }
>                                                                                 }       print $minute2;
>         close($wordlisting1) or die "couldn't close wordlisting: $!";
>                 }
> close $out_file or die "Can't close out_file $!";
>  }#closing  for my minute loop
>
> k

I found the problem. Added this at the beginning:
for my $minute2 (00..59) {
if($minute2<10) {
      $minute2="0$minute2";
   } else {
      $minute2=$minute2;
   }

 ....

k



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

Date: Mon, 10 Sep 2007 02:40:31 +0200
From: Anno Siegel <anno4000@radom.zrz.tu-berlin.de>
Subject: Re: Switching with case in perl ?
Message-Id: <5kji3vF3vuegU1@mid.dfncis.de>

> On Sep 10, 2:58 am, lerameur <leram...@yahoo.com> wrote:

[...]

> I found the problem. Added this at the beginning:
> for my $minute2 (00..59) {
> if($minute2<10) {
>       $minute2="0$minute2";
>    } else {
>       $minute2=$minute2;
>    }

That can be achieved simpler using Perl's magical string increment:

    for my $minute2 ( '00' .. '59' ) {
        # ...

Anno



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

Date: Sun, 09 Sep 2007 17:46:43 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189385203.504494.97740@g4g2000hsf.googlegroups.com>

On Sep 10, 3:40 am, Anno Siegel <anno4...@radom.zrz.tu-berlin.de>
wrote:
> > On Sep 10, 2:58 am,lerameur<leram...@yahoo.com> wrote:
>
> [...]
>
> > I found the problem. Added this at the beginning:
> > for my $minute2 (00..59) {
> > if($minute2<10) {
> >       $minute2="0$minute2";
> >    } else {
> >       $minute2=$minute2;
> >    }
>
> That can be achieved simpler usingPerl'smagical string increment:
>
>     for my $minute2 ( '00' .. '59' ) {
>         # ...
>
> Anno

wow  ok , thanks

I guess one more thing I did not see is the file name.
open(my $out_file, '>>$logtime$timestamp.txt') or die "Can't open
Log.txt$!";

The file name that is being created has the name $logtime
$timestamp.txt
it should the the time from the timestamp I created earlier.
I tried double quoting. what should I sue for the punctuation there.
Also tried using the same syntax of a simple open file command, that
uses double quote, and no success there either.

thanks
k



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

Date: Sun, 09 Sep 2007 20:03:24 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Switching with case in perl ?
Message-Id: <b_qdnVuSkMmsKXnbnZ2dnUVZ_gCdnZ2d@comcast.com>

lerameur wrote:

> I guess one more thing I did not see is the file name.
> open(my $out_file, '>>$logtime$timestamp.txt') or die "Can't open
> Log.txt$!";
> 
> The file name that is being created has the name $logtime$timestamp.txt

Do you know the difference between '' and "" ?  If you don't, you should
stop what you're doing, find a good reference book on Perl, and learn
that before proceeding.  The single quotes are the cause of that problem.

> Also tried using the same syntax of a simple open file command, that
> uses double quote, and no success there either.

A good debugging step is to create additional variables and print out
exactly what you're attempting to accomplish.  For instance, the die() in
the open() statement above is a lie: you are not trying to open "Log.txt".

   my $logname = "$logname$timestamp.txt".
   open my $out_file, ">>$logname" or die "Can't open $logname: $!";
		or
   open my $out_file, '>>', $logname or die "Can't open $logname: $!";

The latter is known as the three-argument open(), and is recommended.

	-Joe


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

Date: Sun, 09 Sep 2007 23:32:21 -0700
From:  Ron Bergin <rkb@i.frys.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189405941.203548.219060@57g2000hsv.googlegroups.com>

On Sep 9, 4:39 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Ron Bergin <r...@i.frys.com>:
>
> > It doesn't appear that you're using the strict or warnings pragmas.
> > It would help if you ask Perl why it can't open the Loog_rr.txt file.
> > It would also be better to put that open call prior to the glob.
> > You also need to make your code easier to read/maintain by reducing
> > the amount of indentation.
>
> > open(my $out_file, '>>', 'Loog_rr.txt') or die "Can't open Loog_rr.txt
> > $!";
>
> > while (my $filename = glob("*$year$month$day$hours$minute*") ){
> >    open($wordlisting1, '<', $filename) or die "Could not open
> > wordlisting: $!";
> >    while (my $line = <$wordlisting1> ) {
> >       if ($line =~ m/beth/) {
> >          @items =  (split(",",$line))[0..3];
>
> You mention strictures above, but @items is not declared anywhere.

Yes, that was a little faux pas on my part which would have revealed
itself when running under strict.
>
> Except for the very special case of ' ', the first argument to split is
> a regex. You should write it as a regex so people don't misread it:
>
>     my @items = ( split( /,/, $line ) )[0..3];
>
> >          print $out_file join(',', @items) , ";\n";

You are right again, I should have written it as a regex, however it
does work as written.
>
> This can be made cleaner by using Perl's print-control variables: put
>
>     local ($,, $\) = (',', ';\n');
>
> at the top of the loop and then simply
>
>     print $out_file @items;
>
Here I have to disagree.  While the print statement itself is cleaner,
the reassignment of the $OUTPUT_FIELD_SEPARATOR and
$OUTPUT_RECORD_SEPARATOR makes it less clear for the beginner, which
is where the OP clearly falls in.

Also, since you're suggesting to do that reassignment "at the top of
the loop" (instead of prior), you're doing it at each iteration of the
loop, which doesn't make sense to me.

> >       }
> >    }
> >    close($wordlisting1) || die "couldn't close wordlisting: $!";
>
> You want to be consistent about whether you use || or 'or' to check for
> errors. Personally I'd always use 'or'; but then I'd always omit the
> parens on open as well.

I agree, consistency is important.
>
> There's little point in checking for errors on close if you haven't
> checked for errors as you read. What errors could occur at this point
> that you care about?
>
> > }
> > close $out_file or die "Can't close out_file $!";
>
> Again, the point of checking for errors when you close a file you were
> writing to is to ensure all the data got written successfully: if you
> care, you should be checking print succeeded as well.

Here it's a 50/50 decision.  I rarely (almost never) use die or warn
on a close statement, but I included it because the OP was using it
and it doesn't do any harm.  In fact, in some cases it would be
recommended, such as when closing a piped open.  I've seen people do
aa die statement on each and very print statement which is totally
ridiculous.
>
> Ben



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

Date: Mon, 10 Sep 2007 02:50:12 -0000
From:  deanjones7@gmail.com
Subject: Re: What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?
Message-Id: <1189392612.633354.212020@g4g2000hsf.googlegroups.com>

Mark Clements wrote:
> deanjones7@gmail.com wrote:
> > Anno Siegel wrote:
> >> On 2007-09-06 10:17:09 +0200, usenet@DavidFilmer.com said:
> >>
> >>> On Sep 6, 1:06 am, deanjon...@gmail.com wrote:
> >>>> the perl script fails without any errors when the system is booted.
> >>> That means NOTHING.  How do you know it fails?  How do you even know
> >>> it runs?  Why would you think it should run on a reboot?
> >> Well, the subject mentions "... launched from rc scripts" which I take
> >> to mean it is called from one of the /etc/*.rc scripts (or however these
> >> are organized in HPUX).
> >
> > That's correct. There's a start/stop script in /sbin/init.d with the
> > usual links to the rc? directories. That script works correctly when
> > run interactively.
>
> Add some logging to the script? I'd use Log::Log4perl or one of the
> syslog alternatives.
>
> $logger->info("starting up");
> ...
>
> $logger->debug("processing line number $count");
>
> $logger->info("exiting normally");
>
> ...
>
> and
>
> (assuming you've wrapped the main body of the program in eval {} )
>
> $logger->error("exiting abnormally with error=$@");

I just tried a "set -x" in the shell script that acts as a wrapper to
the real stuff then ran that from cron.

For some strange reason, cron assigns a pty to the process! So I get
gore like this -

ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
Not a terminal
logout

At the start even though I do -

if tty -s; then
 ...
fi

in the .profile of the account this runs under. Ver odd.

Anyway, the rest of the "set -x" output doesn't show anything amiss -
although it appears that POSIX shells start the program on the
receiving end of a pipe before the program on the front of a pipe. Not
really relevant here, just something I didn't know before.



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

Date: Mon, 10 Sep 2007 03:10:45 -0000
From:  deanjones7@gmail.com
Subject: Re: What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?
Message-Id: <1189393845.232943.317790@50g2000hsm.googlegroups.com>

Anno Siegel wrote:
> On 2007-09-06 14:05:18 +0200, deanjones7@gmail.com said:
>
> > Anno Siegel wrote:
> >> On 2007-09-06 10:17:09 +0200, usenet@DavidFilmer.com said:
> >>
> >>> On Sep 6, 1:06 am, deanjon...@gmail.com wrote:
> >>>> the perl script fails without any errors when the system is booted.
> >>>
> >>> That means NOTHING.  How do you know it fails?  How do you even know
> >>> it runs?  Why would you think it should run on a reboot?
> >>
> >> Well, the subject mentions "... launched from rc scripts" which I take
> >> to mean it is called from one of the /etc/*.rc scripts (or however these
> >> are organized in HPUX).
> >
> > That's correct. There's a start/stop script in /sbin/init.d with the
> > usual links to the rc? directories.
>
> It would have been a good idea to mention that explicitly in the body of
> your posting.  "Launched from rc" is not part of any standard terminology.

I would have expected any experience Unix person to know what an rc
script is and the related terminology, but no matter.

> > That script works correctly when
> > run interactively.
> >
> >> These scripts run at boot time to set up the
> >> system and thus run at a time when the system is not yet completely set
> >> up.  Lots of things can go wrong if something is called too early in the
> >> process.
> >
> > The funny thing is I have another perl script that runs fine when run
> > at boot.
>
> The behavior depends heavily on *when* the script is run during the
> startup process.  "Run at boot" is much too unspecific.

OK, run level 3. About one of the last scripts to run.

> >  The only difference is that its not listening on a pipe like
> > the problematic one is.
>
> The Perl scripts aren't identical, are they?

Its the same script. The only difference I can see is the fact that
there's no pseudo-tty attached to the processes run from init.d.

> I bet the pipe isn't the only difference.  In fact, pipe behavior sounds like a rather unlikely
> candidate.

Yes, I don't think it is. There was one point where I had an explicit
exit in the perl script after it read in a config file (I was printing
the config options back out to ensure it was doing it correctly). The
exit caused the other program on the front of the pipe to die. I then
spent some time trying to work out if it was a SIGPIPE problem (by
sending kill -PIPE signals to that program) to no effect. So the exit
in the perl script must send a different signal back (although I'm not
sure why. I would expect SIGPIPE but HP-UX has some oddities).

> > I wonder if its how I use STDIN. In the problematic script I just do -
> >
> > while (<>)
> > {
> > ...
> > }
> >
> > to read input from the pipe. Should I be using STDIN explicitly
> > instead?
>
> I have no idea.  Post the code of the script, the actual call, and
> describe in what stage of startup the call happens.

Its a bit difficult due to commercial obligations (contracts, etc. I'm
sure you're aware of the issues).

Anyway, if you must know, I took an existing perl script found here -
http://www.peppler.org/downloads/scripts (Its the one called
log_watcher.pl.)
and modified it to read from stdin (i.e. a pipe) rather than from a
file location. I also optimised the regexps and cleaned up some of the
logic. It all works fine (at least when I start the scripts
interactively).

> Is perl even part of the HPUX 11 distribution?

I have no idea. 'perl -v' reports -

This is perl, v5.8.0 built for PA-RISC1.1-thread-multi
(with 1 registered patch, see perl -V for more detail)

> Are all modules your script may be using?

I'm not sure what you mean.

> In fact, you might be better off asking in a HPUX-oriented newsgroup.
> The problem may not be specific to perl at all.

I can't find a specific HP-UX group under comp.unix.*. I might try a
generic one later if I still can't solve this.



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

Date: Mon, 10 Sep 2007 03:20:36 -0000
From:  deanjones7@gmail.com
Subject: Re: What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?
Message-Id: <1189394436.935497.7750@19g2000hsx.googlegroups.com>

Anno Siegel wrote:
> On 2007-09-06 13:59:58 +0200, deanjones7@gmail.com said:
>
> > use...@DavidFilmer.com wrote:
> >> On Sep 6, 1:06 am, deanjon...@gmail.com wrote:
> >>> the perl script fails without any errors when the system is booted.
> >>
> >> That means NOTHING.  How do you know it fails?
> >
> > Because if it was running I would see it with "ps -ef"
>
> Would you?

Yes. If its not showing up under a ps listing but the program on the
front of the pipe is, I think you can safely surmise that the perl
script has died.

> How long does that thing run?

Its a log monitor. It should run as long as the program on the front
of the pipe runs.

> Do you even have
> an interactive process to run ps from when the script is
> supposed to be starting?

I'm not sure what your asking. I can run top, glance or ps. Its a bit
hard to do that when the system is booting, of course.

> >  and it would be
> > reporting errors as they come through the pipe.
>
> Reporting to where?

Email for now. See the original. It also pages but I still have to
modify that part for local use.

> And what errors?

Errors that the program on the front of the pipe might report.

> Last thing you were in doubt if the pipe even works.

I was? The pipe works fine. Its the manner of starting the main script
(boot time or interactively) that seems to be the problem. The only
difference there is that there's no pty attached to the processes. I
can't identify anything as being an issue. For now, anyway.

> How can you rely on it to show if the script is started?

I'm not sure what you mean. The pipe is just part of the process in
the calling shell script.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 835
**************************************


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