[21691] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3895 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 1 18:05:40 2002

Date: Tue, 1 Oct 2002 15:05:11 -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           Tue, 1 Oct 2002     Volume: 10 Number: 3895

Today's topics:
        A simple form problem!  <ReplyToGroup@thanks.com>
    Re: A simple form problem!  <abeall@hotmail.com>
    Re: Beginning Perl <phantommzzz@yahoo.com>
        compiling perl on IRIX... (James A. Cubeta)
    Re: Convert Perl script to C program (and Why was this  <Cpt.Fredo@SS.NoSpam>
    Re: Convert Perl script to C program (and Why was this  <flavell@mail.cern.ch>
        Downloading from a www server: Problem develop@gistenson.com
    Re: Downloading from a www server: Problem (Tad McClellan)
    Re: dynamic pattern matching <yflee@americasm01.nt.com>
    Re: File::Copy troubleshooting <Tassilo.Parseval@post.rwth-aachen.de>
    Re: File::Copy troubleshooting (Tad McClellan)
        Fuzzy text string match code needed (Aaron D. Fuegi)
    Re: Fuzzy text string match code needed (Tad McClellan)
    Re: How can I count files in a directory? (Mike Cardeiro)
    Re: How can I count files in a directory? (Peter J. Acklam)
        module Vs package <sriva@invalid_nospam.com>
        Performance burden in modularization ? <jim.bloggs@eudoramail.com>
    Re: Perl+Cron ... trouble running system() (Paul .)
        reading Cobol PIC 9(6)V99 formats... <jpagnew@vcu.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 1 Oct 2002 22:17:41 +0100
From: "Simon Harvey" <ReplyToGroup@thanks.com>
Subject: A simple form problem! 
Message-Id: <Shom9.11757$J47.1041932@stones>

Hi guys,

Thanks to anyone who can poijt me in the right direction with this one. I
would so appreciate a helping hand on the following problem. I'm sure its
really easy if you know the right function!:

The problem:


Script A generate an html page with a number of checkboxes, on the fly. The
number of checkboxes created depends on the number of clubs in a database
table (Fewer than 20)

Here the main bit:


When the html form submits to script B, how do I get the information on
which checkboxes have been ticked into the recieving script?. The point
being I DON'T even know how many checkboxes there are. The only way I know
how to get form data is if I know the name in advance, then I can use the
param function in the CGI package. That's nice and easy but obviously I cant
right 25 param statements to make sure i get all the check boxes!

How would you go about handling this sort of situation?


I was hoping I could do something like this:

While (there are more form elements){
      Do Stuff();
}


Please, please say there is a nice fluffy and easy answer to this in perl. I
cant find anything like that, but how else would you deal with not knowing
the exact names of the form elements?

Thanks so much to anyone who can point me in the right direction

Kindest Regards

Simon





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

Date: Tue, 1 Oct 2002 16:31:40 -0500
From: "Art" <abeall@hotmail.com>
Subject: Re: A simple form problem! 
Message-Id: <1033507841.86420@sj-nntpcache-5>

One simple way I have used to get around this problem is as follows.
First, I name all my checkboxes in a certain pattern like so with a number
appended like so:
club1
club2
club3
club4

Second, on the same page as above I print out a hidden html field with the
number of checkboxes I just created. When the user submits the form I know
the number of check boxes I had on the previous page and I know how they are
named (club1, club2, club3, club4). Now I can parse out the information I
need with one subroutine.

"Simon Harvey" <ReplyToGroup@thanks.com> wrote in message
news:Shom9.11757$J47.1041932@stones...
> Hi guys,
>
> Thanks to anyone who can poijt me in the right direction with this one. I
> would so appreciate a helping hand on the following problem. I'm sure its
> really easy if you know the right function!:
>
> The problem:
>
>
> Script A generate an html page with a number of checkboxes, on the fly.
The
> number of checkboxes created depends on the number of clubs in a database
> table (Fewer than 20)
>
> Here the main bit:
>
>
> When the html form submits to script B, how do I get the information on
> which checkboxes have been ticked into the recieving script?. The point
> being I DON'T even know how many checkboxes there are. The only way I know
> how to get form data is if I know the name in advance, then I can use the
> param function in the CGI package. That's nice and easy but obviously I
cant
> right 25 param statements to make sure i get all the check boxes!
>
> How would you go about handling this sort of situation?
>
>
> I was hoping I could do something like this:
>
> While (there are more form elements){
>       Do Stuff();
> }
>
>
> Please, please say there is a nice fluffy and easy answer to this in perl.
I
> cant find anything like that, but how else would you deal with not knowing
> the exact names of the form elements?
>
> Thanks so much to anyone who can point me in the right direction
>
> Kindest Regards
>
> Simon
>
>
>




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

Date: Tue, 01 Oct 2002 18:23:42 GMT
From: Gizvee <phantommzzz@yahoo.com>
Subject: Re: Beginning Perl
Message-Id: <3D99EA88.2060206@yahoo.com>

Gyzmo wrote:
> Hi,
> 
> I'm looking for advice on getting perl installed on my pc running XP &
> Debian Linux.I'd like to try and teach myself the language in order to write
> programs for the unix,linux and microsoft environments.
> 
> Is there a good Development Environment that you can recommend ?
> 
> Thank You,
> Graham.
> 
> 

Check out http://anjuta.sourceforge.net/  it`s an IDE made for C and C++
but has alot more to offer.

have a good one

The Real Giz `Mo



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

Date: Tue, 01 Oct 2002 21:22:25 GMT
From: jcubeta@sgi.com (James A. Cubeta)
Subject: compiling perl on IRIX...
Message-Id: <3d99f165.16929142@news.engr.sgi.com>

Greetings!

I am having problems trying to compile Perl 5.8.0 on IRIX.

First, let me say that I am a *complete* Perl newbie, so please
forgive me if this topic is really simple or if I'm doing something
stupid.

In any case, here are the particulars:

As I said, I am trying to compile perl 5.8.0 on IRIX 6.5.17 using
SGI's compiler. I want a 32-bit version and I want ithreads support.
So am giving the following commands to the Configure tool:

   sh ./Configure -Dcc="cc -n32" -Duseithreads -d

When I attempt to "make", I get the following errors on the
compilation of gv.c (the third file in):

=========================
        `sh  cflags "optimize='-O3'" gv.o`  gv.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME
-woff 1184,1552 -OPT:Olimit=0:space=ON -I/usr/include
-I/usr/freeware/include -I/usr/local/include -I/usr/gnu/include
-DLANGUAGE_C -O3 
cc-1020 cc: ERROR File = gv.c, Line = 1693
  The identifier "copy" is undefined.

      RvDEEPCP(left);
      ^

cc-1162 cc: ERROR File = gv.c, Line = 1693
  Too few arguments in function call.

      RvDEEPCP(left);
      ^

cc-1018 cc: ERROR File = gv.c, Line = 1693
  An unmatched left parentheses "(" appears in an expression.

      RvDEEPCP(left);
      ^

3 errors detected in the compilation of "gv.c".
*** Error code 2 (bu21)
==========================

Any ideas as to what is going wrong? Again, I apologize if this is
trivial or not enough information. Please respond via email if
possible.

Thanks!
James
james a. cubeta                                            www.sgi.com
senior systems engineer                                jcubeta@sgi.com
----------------------------------------------------------------------
sgi federal                                        voice: 703.227.8543
14160 newbrook drive                              mobile: 703.624.5689
suite 100                                       sgi vnet:     528.8543
chantilly, va 20151                                  fax: 703.227.8500


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

Date: Tue, 01 Oct 2002 21:12:00 GMT
From: ".Fredo" <Cpt.Fredo@SS.NoSpam>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <Acom9.967$jd1.112608538@newssvr14.news.prodigy.com>


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnapgk9o.25c.tadmc@magna.augustmail.com...
>
> It would seem so obvious to anyone who knows a bit about security
> that I didn't think it would need explaining.
>
> One of the biggest of security bugaboos is a sense of false security,
> because then you think you have it "covered" until it becomes
> uncovered (ie. when it is too late).
>
>
> > P.S. Did you even read past the first two lines?
>
>
> Yes. Compiling is platform specific and I have no experience with
> the target platform, so I was unable to help with that part.

While that is true, Perl does come with a tool for converting a perl
script to c or cpp files. It may be a third-party tool, don't know for
sure, but I believe it come with Perl.

> > He perfectly described
> > what he wanted to do,
>
>
> Yes, but not *why* he wanted to do it.

Yes he did. I clearly stated he wanted to "keep them from prying eyes",
which would seem to be his reason. I never said it

> My followup was probing to find out what it is that he hopes to
protect.
>
> The first step in "securing" something is to decide _what_ it
> is that you want to secure against: piracy, unauthorized modification,
> discovery of the algorithm or sensitive embedded data (eg. passwords,
> CC numbers...).

Yes but your reply was misleading and actually carries the appearance of
being rude. Forgive me, but seeing as many of your responses in recent
years have been decorated with not so friendly tones, surely you can see
why I responded as such.

> You also need to assess the "cost" of being compromised so that you
> can decide how much to spend on the security measures.
>
> Since he didn't mention any of that, I thought it possible (likely)
> that he had fallen prey to a common mistake.

I wouldn't doubt it. He has the appearance of one who is just learning.

> I was just making sure that that was not the case.
>
>
> > and I already explained in another post
>
>
> That was posted several hours later than my article you've
> quoted here.
>
> You seem to expect that I had already seen it when I wrote
> what I wrote.
>
> I cannot see into the future.

I honestly do not know what you mean here. I replied to you. Most people
would that after you post something, it is typical that you would come
back to see if your post gathered any replies.

> And it does not matter what you or I or the dictionary mean by
> "encryption", we need to know what the _OP_ meant he said it.
>
> Compiling it to C will only protect it from _some_ prying eyes.
>
> The OP had no such qualification, so I assume it means all prying
eyes.
>
>
> > how that
> > statement of yours can actually be wrong.
>
>
> But not in the context of keeping them from prying eyes.
> Compiling does not do that. It only reduces the number of
> eyes that can pry.
>
> It also seems a stretch to consider the general public's definition
> of the term rather than the "Computer Science" definition of the
> term, given that we are posting under the comp.* hierarchy.
>
> Compiling to C does not prevent access by "unauthorized parties".

Well the source is easy enough to read and muck with, but once compiled,
it would really need to be decompiled in some manner to be read
effectively.

> > If you can't really offer
> > anything to a discussion,
>
>
> Since you seem familiar enough with my posting history to feel
> comfortable assigning me a nickname, you have perhaps noticed
> that I _am_ helpful more than occasionally.

Well I do not deny you certainly started out as quite a helpful soul. It
was when you started with the ill toned replies to the less programming
savvy or questions that you've deemed as less relevant to this group.

That brings me to en interesting question. Why was this group created
with the suffix "misc", which indeed is seen as the abbreviation for
"miscellaneous", so strict that everything needs to be a 100% perl
question? Why was it named misc?

Actually from reading the charter for this group, it used to be at one
time called comp.lang.perl, which was deleted (though it still seems to
exist on many groups.) It would seem the biggest cause of the "flood of
newbies" (as someone once put it) is that very name of the group. It
would seem to have been a lot more effect to keep to "use strict" perl
(pun intended) in comp.lang.perl, where this group was derived from. The
name of this group makes little sense in the way it's purpose is
proclaimed by the "regulars".

> If someone who had demonstrated clue says something that you
> do not understand, you might consider asking for an explanation,
> as it seems likely that there was some reason.
>
>
> > then please don't come into it.
>
>
> Review your followup, note what it adds to the discussion.
>
> Do you see any irony there?

Not really. In your short little reply, you had little to offer, but a
misleading reply (to the OP mainly). I seemed like just another one of
your rude posts, and you ending here does little persuade otherwise.




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

Date: Tue, 1 Oct 2002 23:24:04 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <Pine.LNX.4.40.0210012321240.4865-100000@lxplus074.cern.ch>


On Oct 1, .Fredo replied to Tad:

[far too much for comfort]

> > Do you see any irony there?
>
> Not really. In your short little reply, you had little to offer, but a
> misleading reply (to the OP mainly). I seemed like just another one of
> your rude posts, and you ending here does little persuade otherwise.

I could see this coming.  A well-earned killfile entry.  Please
don't change your posting address.



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

Date: Tue, 1 Oct 2002 19:16:16 +0000 (UTC)
From: develop@gistenson.com
Subject: Downloading from a www server: Problem
Message-Id: <ancsa0$lek$1@flood.xnet.com>

Hi,
I have three questions

First, I am writing scripts in PERL for a web site and need server-side 
code so that when the user at the client-side clicks on the appropriate 
html link in my server web page, a binary file is downloaded from the 
server to the user's computer. Is lwp the best way to do this?

Second, where can I find online documentation for lwp? I can't use pdf or 
printed documentation. 
Third, what's wrong with the first line of code, below? I copied it from a 
response to someone else's question about how to transfer a binary file 
from a server to a client. When I issue the UNIX command line command: 
perl -c download.cgi (the script's name), I get the error shown below 
after the script. (The first two lines of the script, below, are actually 
one line of code; it wrapped here in my post.)

Here's the script:

perl -MLWP::Simple -e 'binmode STDOUT ;getprint 
"http://www.gistenson.com/picture.jpg";'>received.jpg
exit;
__END__

Here's the command line command I issued to check for syntax errors and 
the results (The greater than symbol (>) is the command line prompt):

> perl -c download.cgi
syntax error at download.cgi line 1, near "MLWP::Simple -e "
Execution of download.cgi aborted due to compilation errors.
>

Thanks for any help,
Dan
                                                                               


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

Date: Tue, 01 Oct 2002 21:51:43 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Downloading from a www server: Problem
Message-Id: <slrnapk643.29k.tadmc@magna.augustmail.com>

develop@gistenson.com <develop@gistenson.com> wrote:


> where can I find online documentation for lwp? 


Wherever you installed the module:

   perldoc LWP
   perldoc LWP::Simple

The docs come with the module itself.


> Third, what's wrong with the first line of code, below? 


Nothing.

It is a one-liner to be executed directly at the command line.

It worked fine (404 Not Found) when I tried it.


> I copied it 


You should understand it before you use it. If you don't 
understand it when you see it, then ask about it.


> When I issue the UNIX command line command: 
> perl -c download.cgi 


You should check for warnings at the same time:

   perl -cw download.cgi 


> (the script's name), I get the error shown below 


> Here's the script:
> 
> perl -MLWP::Simple -e 'binmode STDOUT ;getprint 
> "http://www.gistenson.com/picture.jpg";'



You can convert from a one-liner to a program in a file:

---------- download.cgi  ------------------   
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;

binmode STDOUT ;
getprint 'http://www.gistenson.com/picture.jpg';
-------------------------------------------


I added warnings and strictures too, because I do that
on all of my programs. You should too.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 1 Oct 2002 14:49:38 -0400
From: "Lee, YuenFai [CAR:1908:EXCH]" <yflee@americasm01.nt.com>
Subject: Re: dynamic pattern matching
Message-Id: <ancqjj$2up$1@bcarh8ab.ca.nortel.com>

$my_expression = "expression";
if (/$my_expression/) ...

"Brutus" <pef@trasig.noXX> wrote in message
news:anc0q5$7dn$1@oslo-nntp.eunet.no...
> Usually pattern matching is hard coded, e.g.:
> if (/ "expression" /)
>
> But what if  "expression" is a scalar variable ?
> I'm looking for the syntax for finding the occurance of an expression
> ( contained in a scalar ) in another scalar.
>
> I've been looking in the books, without any luck so far.
>
> Thankful for a pointer.
> Brit Uthus
>
>
>
>
>
>




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

Date: 1 Oct 2002 18:25:03 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: File::Copy troubleshooting
Message-Id: <ancp9v$q07$1@nets3.rz.RWTH-Aachen.DE>

Also sprach michael.e.grimes@fritolay.com:

> I use the File::Copy module in one of my scripts as follows:
> 
> copy("$Full_Origin_Path","$Full_Dot_Share_Path") || &NT_Proc(50, "$Start -
> $ENV{COMPUTERNAME} $0 failed on copy", "$Period\_50");
> 
> Sometimes, the copy fails and the NT_Proc subroutine executes a page stating
> that the copy has failed. I would like to know why the copy is failing. Can
> someone suggest a method for capturing the standard error or any other method
> for tracking down exactly why the copy is failing?

Yes, simply inspect $!, so adjust your NT_Proc() function (and please,
also get rid of this ugly ampersand (&). It does more harm than goods.

    ... || NT_Proc(50, "$Start - $ENV{COMPUTERNAME} $0 failed on copy",
                   "${Period}_50", $!);
                                   ^^
                                   ^^
                        will tell you, what went wrong

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Tue, 01 Oct 2002 18:27:08 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: File::Copy troubleshooting
Message-Id: <slrnapjq3a.1ug.tadmc@magna.augustmail.com>

michael.e.grimes@fritolay.com <michael.e.grimes@fritolay.com> wrote:

> I use the File::Copy module in one of my scripts as follows:


> I would like to know why the copy is failing. Can
> someone suggest a method for capturing the standard error or any other method
> for tracking down exactly why the copy is failing?


   perldoc File::Copy

--------------------------------------
RETURN
       All functions return 1 on success, 0 on failure.  $! will
       be set if an error was encountered.
--------------------------------------


Output the $! variable in your diagnostic message.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 1 Oct 2002 19:01:45 GMT
From: aarondf@bu.edu (Aaron D. Fuegi)
Subject: Fuzzy text string match code needed
Message-Id: <ancrep$7bu$1@news3.bu.edu>

	I am wondering if anyone can direct me to code for doing fuzzy string
matches of text strings.  Basically, I have a list of strings (game names
in actuality) and, given another string, I want to know if it matches any
of the existing strings, preferrably with some confidence percentage.  I would
want it to handle things like:

Capitalization differences
Misspellings such as a missing letter or transposed characters.
Extra/different punctuation like "&" vs "and" and having/not having such
	things as ":" "!" or ",".
Phoenetic errors
Skipping articles like "The" or "Die" since some of these names are in German.

	Specific examples of the types of names I am dealing with are at
http://scv.bu.edu/~aarondf/Top100/list.txt 

	Responses by email to aarondf@bu.edu preferred.

Aaron
aarondf@bu.edu




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

Date: Tue, 01 Oct 2002 21:05:11 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Fuzzy text string match code needed
Message-Id: <slrnapk34f.26u.tadmc@magna.augustmail.com>

Aaron D. Fuegi <aarondf@bu.edu> wrote:

> 	I am wondering if anyone can direct me to code for doing fuzzy string
> matches of text strings.


   http://search.cpan.org/author/JHI/String-Approx-3.19/Approx.pm


> 	Responses by email to aarondf@bu.edu preferred.


Preferred by _you_, whereas the alternative, responses to the newsgroup,
are preferred by thousands of others.

Please do not hoard responses in email, let them be posted here
to be shared with the world.

Ask it here, get the answer here (maybe).


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 1 Oct 2002 12:42:43 -0700
From: mcardeiro@yahoo.com (Mike Cardeiro)
Subject: Re: How can I count files in a directory?
Message-Id: <63ac3571.0210011142.66473e91@posting.google.com>

"Ilya Sterin" <isterin@nospam.com> wrote in message news:<ancc48$i3i15@eccws12.dearborn.ford.com>...
> my $dir = opendir("path/to/dir");
> 
> my $count;
> 
> $count++ while (readdir($dir));
> 

this does not account for th dot files (. and ..) of some operating
systems, which I do not think the original poster would want counted
as files in their directory

Mike Cardeiro


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

Date: Tue, 01 Oct 2002 20:19:37 GMT
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: How can I count files in a directory?
Message-Id: <k7l129nj.fsf@online.no>

mcardeiro@yahoo.com (Mike Cardeiro) wrote:

> "Ilya Sterin":
>
> > my $dir = opendir("path/to/dir");
> > 
> > my $count;
> > 
> > $count++ while (readdir($dir));
> 
> this does not account for th dot files (. and ..) of some operating
> systems, which I do not think the original poster would want counted
> as files in their directory

Not to mention that the loop stops as soon as it finds a file or
directory named `0'.  And there is check on the return value from
opendir().

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Tue, 01 Oct 2002 17:44:23 -0400
From: Sriva <sriva@invalid_nospam.com>
Subject: module Vs package
Message-Id: <3D9A1737.1090604@invalid_nospam.com>

Hi,
   A newbie question.

    I am trying to figure out why we need BOTH modules and packages in 
perl.  It appears as if the only new feature that a module provides over 
a package is:
       You have a shorthand notation of accessing the subroutines..  i.e 
like  funcName(xxx)  rather than package::funcName(xxx).

Question_1:  If a main uses 2 different modules, and funcName exists is 
both modules,  then can those functions still be invoked from main? 
maybe using module1::funcName()  and module2::funcName()?

Question_2:  If modules are more convenient, than why do we need 
packages at all?

-Sriva



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

Date: Tue, 1 Oct 2002 22:38:33 +0100
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Performance burden in modularization ?
Message-Id: <and4kq$d30gc$1@ID-150435.news.dfncis.de>

Hi,

This is not a pressing issue, but just a passing wonderment. I've grown
to like using object-oriented style coding in perl which tends to
result, at least the way I do it, in breaking up a long spiel into
several modules all of which will require to be read from disk at
runtime. Is there much of an overhead in reading these modules from
disk, especially in the CGI context where each request normally requires
a new instance of interpretation, if you know what I mean. ( mod_perl
excepting, that is ).

Does that make any sense. What i'm asking is whether there is any
performance burden in breaking up code into modules, and if so, how much
concern I ought to give it.

--
I very much hope you can be of some assistance ..
Perhaps thankyou is a little premature. ;-)~
Best Wishes,
Doofus




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

Date: 1 Oct 2002 11:35:57 -0700
From: x31forest@hotmail.com (Paul .)
Subject: Re: Perl+Cron ... trouble running system()
Message-Id: <aa5923ca.0210011035.320bfaa0@posting.google.com>

dfederighi@yahoo.com (dale federighi) wrote in message news:<1018a300.0209301700.10a9dda5@posting.google.com>...
> Hello All,
> I am running a perl script that checks to see if the Tomcat server is
> down, and if it is, does a simple restart (through system() and calls)
> /usr/tomcat4/bin/startup.sh. When I run this on the command line, NO
> PROBLEMS, but when I try to run is as a cronjob ... nothing, but
> /var/log/cron just spits out the status as if it ran without problems.
> FRUSTRATED HERE!
> 
> Here is the perl script (pretty basic stuff):
> 
> #!/usr/local/bin/perl -w
> #
> # File: check_servers.pl
> # Author: dale federighi <dale@federighi.net>
> #
> #
> ################################################################################
> 
> use strict;
> 
> use POSIX;
> 
> # logfile title format: catalina_log.2002-09-27.txt
> my $curr_date = strftime( "%Y-%m-%d", localtime );
> my $curr_file = "catalina_log." . $curr_date . ".txt";
> 
> # get the contents of the logfile for today ...
> open(TCAT_FILE, "</usr/tomcat4/logs/$curr_file" ) || die "Cannot open
> file: $!";
>         my @LOG_LINES = <TCAT_FILE>;
> close(TCAT_FILE);
> 
> # flag we are using to get the current state
> # of the server.
> my $tomcat_started = 0;
> 
> foreach my $line(@LOG_LINES)
> {
>         if( $line =~ /Starting/ )
>         {
>                 $tomcat_started = 1;
>         }
>         else
>         {
>                 $tomcat_started = 0;
>         }
> }
> 
> if( $tomcat_started == 0 )
> {
>         chdir( "/usr/tomcat4/bin" );
>         system( "/bin/sh startup.sh" );
> }
> 
> ############################################################
> # End script
> 
> I am using full paths where needed, here is my crontab entry:
> */5 * * * * /usr/local/bin/perl /var/www/check_servers.pl
> 
> I have also tried creating a shell wrapper, which executes the perl
> script for me, here is the code for that ( the startup script was
> created with /bin/sh ):
> 
> #!/bin/sh
> #
> # Since CRON seems unable to run Perl scripts with System()
> # calls, I have created this simple wrapper.
> #
> ############################################################
> 
> cd /var/www
> /usr/local/bin/perl check_servers.pl
> 
> ############################################################
> # End Script
> 
> I fully recognize that normally the problem with things like this is
> in the ENVIRONMENT, and the reading of $PATH. However, I have tried to
> safeguard myself and use full paths everywhere .... HELP!
> 
> Not sure what else I can do, I have been as redundancy in my code as a
> possibly can, or have I?
> 
> Also, if anyone knows of a better way to handle the auto-restart issue
> in Tomcat, I would be happy to hear it.
> 
> I have spent more time on this than I care to admit, but I am
> frustrated to say the least.
> 
> Any help is appreciated.
> 
> thanks,
> ~daleF

The problem may lie with terminal stdout or stdin issue. When a
process runs from cron it is not allocated a console, so if it may
require to read or write to STDIN or STDOUT it may fail.
Don't know what your startup.sh does but make sure it doesn't require
an active input and output.
So you can try redirecting it to /dev/null 

/bin/sh startup.sh >& /dev/null would redirect error and output to
null.
 

-Sorin.


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

Date: Tue, 01 Oct 2002 16:06:21 -0400
From: Jim Agnew <jpagnew@vcu.edu>
Subject: reading Cobol PIC 9(6)V99 formats...
Message-Id: <3D9A003C.990A91A0@vcu.edu>

People, subject says it all,

on a VMS system, try to read a Cobol PIC 9(6)V99 formats...

I'm a newbie trying to redo an accounting system from Cobol to something
a little bit less unwieldy...  ;-)

so the question is how can Perl read that stuff? I think I'm wading thru
most else ok, 
just time and beating my head on the books...

jim


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

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.  

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 V10 Issue 3895
***************************************


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