[24242] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6433 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 20 18:06:00 2004

Date: Tue, 20 Apr 2004 15:05:12 -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, 20 Apr 2004     Volume: 10 Number: 6433

Today's topics:
        "cloning" perl / CPAN install (Walter Roberson)
    Re: "cloning" perl / CPAN install <spamtrap@dot-app.org>
    Re: 5.6 to 5.8 CPAN help (Walter Roberson)
    Re: 5.6 to 5.8 CPAN help (Walter Roberson)
    Re: 5.6 to 5.8 CPAN help <jgibson@mail.arc.nasa.gov>
        Bundle::Apache compilation errors <none@none.com>
    Re: Bundle::Apache compilation errors <none@none.com>
    Re: Bundle::Apache compilation errors <none@none.com>
    Re: Bundle::Apache compilation errors <1usa@llenroc.ude>
    Re: Bundle::Apache compilation errors <none@none.com>
    Re: Bundle::Apache compilation errors <spamtrap@dot-app.org>
    Re: Bundle::Apache compilation errors <none@none.com>
    Re: Free source guestbook - unfinished <1usa@llenroc.ude>
    Re: Free source guestbook - unfinished <me@privacy.net>
    Re: Free source guestbook - unfinished <robin @ infusedlight.net>
        incorrect value for HOSTNAME executed as cron job (Julian)
    Re: incorrect value for HOSTNAME executed as cron job <xx087@freenet.carleton.ca>
    Re: incorrect value for HOSTNAME executed as cron job <pkent77tea@yahoo.com.tea>
        Need help with table <orion93@club-internet.fr>
    Re: Need help with table <spamtrap@dot-app.org>
    Re: Need help with table <tadmc@augustmail.com>
    Re: One question <edgrsprj@ix.netcom.com>
    Re: One question <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Apr 2004 20:43:42 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: "cloning" perl / CPAN install
Message-Id: <c6421u$p9k$1@canopus.cc.umanitoba.ca>

I maintain perl installations (often with several different revisions
simultaneously) on multiple computers. As I find I need a CPAN
module (or it looks like it is of interest and I want to read the
documentation for it), I install the module on one system; and then
might end up writing code using that module. At some later point,
I want to bring the other computers in sync with the module set.
If I happen to remember everything I've installed, well and good, but
usually I don't.

Would then, there happen to be a good way to say "install all the
CPAN modules from this version here, to that version over there?"
Presuming that there might be different architectures or versions involved
(e.g., the module :: name is important moreso than copying
the distribution)?

Or perhaps to make this simpler: is there an easy way to figure
out which CPAN modules top-level modules have been installed,
in a form suitable for pasting in to a CPAN 'install' statement 
on another machine (or different version)? I made an attempt at
this by looking through the directory the modules get installed into,
but that directory has system modules as well, and if I just chase
down the directory finding all the .pm's and converting /'s to ::
then I end up trying to install sub components of modules rather than
just getting the official module name that includes all the subcomponents.

cpan itself must have a way of doing this, in order to impliment the
'r' command, but I'd perfer not to have to dig through cpan source
if someone happens to know the answer. (Surely this same functional
requirement happens to many other people as well.)
-- 
   The image data is transmitted back to Earth at the speed of light
   and usually at 12 bits per pixel.


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

Date: Tue, 20 Apr 2004 17:07:56 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: "cloning" perl / CPAN install
Message-Id: <8ZGdnbKwNf6wDBjdRVn-gw@adelphia.com>

Walter Roberson wrote:

> cpan itself must have a way of doing this

The "autobundle" command in the CPAN shell.

> I'd perfer not to have to dig through cpan source

Did you also prefer not to have to dig through the "help" command?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 20 Apr 2004 19:50:47 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <c63uun$l3m$1@canopus.cc.umanitoba.ca>

In article <DF4hc.65268$U83.9863@fed1read03>,
The King of Pots and Pans  <King@ask.for.email.invalid> wrote:
:On Tue, 20 Apr 2004 at 07:14 GMT, Walter Roberson spoke:

:> perl -MCPAN -e shell

:When I attempt to install things using the above it installs them in
:the perl 5.6 dirs. How do I start using the perl 5.8 and configure
:cpan for perl 5.8?

perl5.8 -MCPAN -e shell

CPAN knows about which version of perl you are running, and will
install under the appropriate hierarchy.
-- 
Contents: 100% recycled post-consumer statements.


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

Date: 20 Apr 2004 19:54:31 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <c63v5n$lct$1@canopus.cc.umanitoba.ca>

In article <Fr4hc.65265$U83.53371@fed1read03>,
The King of Pots and Pans  <King@ask.for.email.invalid> wrote:
:I tried su'ing to root and running the command above you
:suggested. But got the original bad @INC path thing:

:[root@sol root]# perl -MCPAN -e shell
:Can't locate CPAN.pm in @INC (@INC contains:
:/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
:/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
:/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
:/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
:/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
:/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .).

Notice the . just before the closing bracket. That dot indicates
the current directory will be examined. So just CD to a directory
that has CPAN.pm in it, and try again. (You might have to then
tell CPAN to install CPAN so it gets stuffed in the expected location...)

As for how to know that this was the way to invoke CPAN:

$ perldoc -m CPAN
[.... lots and lots of code to scroll through]
=head1 NAME

CPAN - query, download and build perl modules from CPAN sites

=head1 SYNOPSIS

Interactive mode:

  perl -MCPAN -e shell;


-- 
Cannot open .signature: Permission denied


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

Date: Tue, 20 Apr 2004 13:04:51 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <200420041304513230%jgibson@mail.arc.nasa.gov>

In article <DF4hc.65268$U83.9863@fed1read03>, The King of Pots and Pans
<King@ask.for.email.invalid> wrote:

> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Tue, 20 Apr 2004 at 07:14 GMT, Walter Roberson spoke:
> 
> > perl -MCPAN -e shell
> 
> When I attempt to install things using the above it installs them in
> the perl 5.6 dirs. How do I start using the perl 5.8 and configure
> cpan for perl 5.8?

Do 'perl -v' to see which perl you are running when you just enter
'perl'. Do 'which perl' to see the path of this executable. It is
probably the 5.6 version.

Find the path to perl 5.8 and do:

   /path-to-perl-5-8/perl -MCPAN -e shell

to run the CPAN shell under 5.8. It will install modules in the 5.8
directories.

Consider deleting the 5.6 installation from your system, or taking the
5.6 out of your command search path. At least put the 5.8 executable
ahead of the 5.6 executable in your path.


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

Date: Tue, 20 Apr 2004 20:34:08 +0100
From: gunzip <none@none.com>
Subject: Bundle::Apache compilation errors
Message-Id: <o_ehc.34966$Y%6.4542518@wards.force9.net>

Just tried installing Bundle::Apache as root on OS X 10.3/Panther. Here are
the errors:

<output>
Can't locate Apache/TestMM.pm in @INC (@INC contains: Apache-Test/lib
/System/Library/Perl/5.8.1/darwin-thread-multi-2level
/System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level
/Library/Perl/5.8.1 /Library/Perl
/Network/Library/Perl/5.8.1/darwin-thread-multi-2level
/Network/Library/Perl/5.8.1 /Network/Library/Perl .) at Makefile.PL line 18.
Running make test
  Make had some problems, maybe interrupted? Won't test
Running make install
  Make had some problems, maybe interrupted? Won't install
Bundle summary: The following items in bundle Bundle::Apache had
installation problems:
  Data::Dumper Apache::Request
</output>

How do I resolve this?

Garry



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

Date: Tue, 20 Apr 2004 20:45:56 +0100
From: gunzip <none@none.com>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <s9fhc.34971$Y%6.4543239@wards.force9.net>

One source advised installing Apache::Test but that produced another error:

Skip the test suite? [No]
make: *** [run_tests] Error 1
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force

Why is it such a pain in the *** getting Perl to work? And we wonder why web
developers have turned in their droves to PHP. This kind of experience is
exactly why.

Garry



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

Date: Tue, 20 Apr 2004 20:57:02 +0100
From: gunzip <none@none.com>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <Sjfhc.34976$Y%6.4544085@wards.force9.net>

Looking closer at the output, this seemed relevant but I'm still no wiser:

<output>
[warning] rerunning '/usr/bin/perl
/private/var/root/.cpan/build/Apache-Test-1.10/t/TEST -bugreport -verbose=0'
with new config opts
[warning] root mode: changing the files ownership to 'nobody'
(4294967294:4294967294)
[warning] testing whether 'nobody' is able to -rwx
/private/var/root/.cpan/build/Apache-Test-1.10/t
"/usr/bin/perl" -Mlib=lib -MApache::TestRun -e 'eval {
Apache::TestRun::run_root_fs_test(4294967294, 4294967294,
q[/private/var/root/.cpan/build/Apache-Test-1.10/t]) }';

[warning] result:
[  error] You are running the test suite under user 'root'.
Apache cannot spawn child processes as 'root', therefore
we attempt to run the test suite with user 'nobody' (4294967294:4294967294).
The problem is that the path (including all parent directories):
  /private/var/root/.cpan/build/Apache-Test-1.10/t
must be 'rwx' by user 'nobody', so Apache can read and write under that
path.

There are several ways to resolve this issue. One is to move and
rebuild the distribution to '/tmp/' and repeat the 'make test'
phase. The other is not to run 'make test' as root (i.e. building
under your /home/user directory).

You can test whether some directory is suitable for 'make test' under
'root', by running a simple test. For example to test a directory
'/private/var/root/.cpan/build/Apache-Test-1.10/t', run:

  % "/usr/bin/perl" -Mlib=lib -MApache::TestRun -e 'eval {
Apache::TestRun::run_root_fs_test(4294967294, 4294967294,
q[/private/var/root/.cpan/build/Apache-Test-1.10/t]) }';

Only if the test prints 'OK', the directory is suitable to be used for
testing.
</output>

Garry



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

Date: 20 Apr 2004 20:19:31 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <Xns94D1A611411Fasu1cornelledu@132.236.56.8>

gunzip <none@none.com> wrote in
news:Sjfhc.34976$Y%6.4544085@wards.force9.net: 

> Looking closer at the output, this seemed relevant but I'm still no
> wiser: 

You can read, can't you?

> [warning] result:
> [  error] You are running the test suite under user 'root'.
> Apache cannot spawn child processes as 'root', therefore
> we attempt to run the test suite with user 'nobody'
> (4294967294:4294967294). The problem is that the path (including all
> parent directories): 
>   /private/var/root/.cpan/build/Apache-Test-1.10/t
> must be 'rwx' by user 'nobody', so Apache can read and write under
> that path.
> 
> There are several ways to resolve this issue. One is to move and
> rebuild the distribution to '/tmp/' and repeat the 'make test'
> phase. The other is not to run 'make test' as root (i.e. building
> under your /home/user directory).

You also said:

> Why is it such a pain in the *** getting Perl to work? And we wonder
> why web developers have turned in their droves to PHP. This kind of
> experience is exactly why.

This issue relates to your lack of knowledge of basic system administration 
skills. 

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Tue, 20 Apr 2004 21:28:25 +0100
From: gunzip <none@none.com>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <hNfhc.34990$Y%6.4546270@wards.force9.net>

A. Sinan Unur wrote:

> You can read, can't you?

>
> This issue relates to your lack of knowledge of basic system administration
> skills.
>

Look, shitface, if I wanted a complete idiot to answer my post, I'd have
asked for one. Go back to your burrow.

Garry



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

Date: Tue, 20 Apr 2004 16:41:08 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <feOdnXcrrMV4Fxjd4p2dnA@adelphia.com>

gunzip wrote:

> Looking closer at the output, this seemed relevant

It's very relevant. It is, in fact, the answer to your question. Have you
tried doing what the warning message says to do? What happened?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 20 Apr 2004 22:05:04 +0100
From: gunzip <none@none.com>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <Ejghc.34997$Y%6.4548807@wards.force9.net>

Sherm Pendley wrote:

> gunzip wrote:
> 
> 
>>Looking closer at the output, this seemed relevant
> 
> 
> It's very relevant. It is, in fact, the answer to your question. Have you
> tried doing what the warning message says to do? What happened?
> 
> sherm--
> 

It seemed relevant to me at first until I looked at

/private/var/root/.cpan/build/Apache-Test-1.10/t/

 ... and discovered it's permissions to be:

drwxr-xr-x   9 nobody  nobody    306 20 Apr 21:35 t

Garry



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

Date: 20 Apr 2004 19:02:15 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Free source guestbook - unfinished
Message-Id: <Xns94D198F7E5E01asu1cornelledu@132.236.56.8>

"Robin" <robin @ infusedlight.net> wrote in
news:c63mud$6fe$3@reader2.nmix.net: 

> my $string = '<--->';
> my $string2 = '<---->';

Use meaningful names for your variables.

> my $LOCK_SH = 1;
> my $LOCK_EX = 2;
> my $LOCK_UN = 8;

Don't do that. See perldoc -f flock.

> my $DATE = getdate();
> my @head = gethead ($headerfile);
> my @foot = getfoot ($footerfile);
> 
> if (url_param ('action') eq "sign")
>  {
>  sign();
>  }
> 
> elsif (url_param ('action') eq "dosign")
>  {
>  dosign();
>  }
> else
>  {

You can benefit from using the CGI::Application module. At the very 
least, you can set up a hash like (untested code type directly into 
newsreader follows):

my %handlers = (
    	'default' => \&default,
    	'sign'    => \&sign,
    	'dosign'  => \&dosign,
    	# etc ...
);

my $q = CGI->new();
my $action = $q->param('action') || 'default';
$handlers{$action}->($q);

You should at the very least read the docs for CGI::Application and 
HTML::Template.

>  if (! -e $bookfile)
>   {
>   if (open (BOOKFILE, ">$bookfile"))
>    {
>    flock (BOOKFILE, $LOCK_EX);
>    print BOOKFILE '';
>    flock (BOOKFILE, $LOCK_UN);
>    close (BOOKFILE);

Don't do that. See perldoc -f flock.

> sub sign
>  {
>  print header;
>  print (@head);
>  print <<END;
> <div align="center">
>   <p><strong>GBOOK2 - Sign Guestbook - Version $version</strong></p>
>   <hr size="1">
>   <form name="form1" method="post" action="gbook.pl?action=dosign">
>     <table width="85%"  border="1" align="center" cellpadding="3"

Do look into HTML::Template.

> sub dosign
>  {
>  if (checkforcookie() eq "true")
>   {
>   #print header;
>   #print (@head);
>   #print ("<center>You have already signed the guestbook once today.
>   Please 
> sign it again tommorow.<hr></center>");
>   #print (@foot);
>   #exit;
>   }

OK, this is getting very entertaining ...

>     if (param ('url') !~ /<.*>/ and param ('webname') !~ /<.*>/ and
>     param 
> ('url') !~ /^\s*$/s and param ('webname') !~ /$string2|$string/ and
> param ('url') !~ /$string2|$string/)

Argh!

>          $website = <<END;
> <a href="$url[1]">$url[1]</a>
> END

Argh! Argh! Argh!

>  if ($name !~ /^\s*$/g and $email !~ /^\s*$/g and $message !~ /^\s*$/g
>  and 
> $email !~ /<.*>/s and param ('webname') !~ /<.*>/g and param ('url')
> !~ /<.*>/g and $name !~ /<.*>/s and $name !~ /$string/g and $message
> !~ /$string/g and $website !~ /$string/g and $email !~ /$string/g and
> $name !~ /$string2/g and $message !~ /$string2/g and $email !~
> /$string2/g and param ('webname') !~ /$string2/g and param ('url') !~
> /$string2/g) 

Sheeeesh! 

>   {
>   open (BOOKFILE, ">>$bookfile") or print header and print "An error
>   occured 
> during this operation: <b>$!</b>. Please press the back button on your
> browser and try again.<hr>" and exit;
>   flock (BOOKFILE, $LOCK_EX);
>   print BOOKFILE <<"END";

Hmmmmm ...

>   flock (BOOKFILE, $LOCK_UN);

Don't do that. See perldoc -f flock

>   close (BOOKFILE);
>   chmod (0770, $bookfile);
>         setcookie ("gbook.pl");

What if the poster's browser is not accepting cookies?

>  flock (BOOKFILE, $LOCK_SH);

Don't do that. See perldoc -f flock.

>  my @contentsofbook=<BOOKFILE>;
>  flock (BOOKFILE, $LOCK_UN);
>  close (BOOKFILE);
>  my $contentsofbook=join('', @contentsofbook);
>  @contentsofbook = split (/$string/, $contentsofbook);
>  @contentsofbook = reverse (@contentsofbook);

If I am not mistake, you have already done some work storing HTML in the 
BOOKFILE. What the heck is going on here?


> sub printpages
>  {
>  return;
>  }

This sub is the best code you have written so far.

> sub printerror1
>  {
>  print header;
>  print (@head);

Try passing arguments to your subs.

> sub gethead
>  {
>  my ($header) = @_;
>  my @header;
> 
>  if (-e "$header")

Useless use of quotes.

> sub getdate
>  {
>  open (DATE, "date +%D|") or print header and print "Date could not be
> obtained. Please contact your system's administrator.<hr>" and exit;

This message is misleading to someone trying to submit an entry to the 
guestbook.


-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Wed, 21 Apr 2004 08:36:39 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Free source guestbook - unfinished
Message-Id: <c641ng$7s7o4$1@ID-172104.news.uni-berlin.de>


"Robin" <robin @ infusedlight.net> wrote in messtage
news:c63mud$6fe$3@reader2.nmix.net...

Thankfully, you do appear to be taking some notice of the advice given by
the experts here (eventually)

> #!/usr/bin/perl -T
>
> use strict;
> use warnings;
>
> use CGI qw(:all);

Good start


> my $LOCK_SH = 1;
> my $LOCK_EX = 2;
> my $LOCK_UN = 8;

use Fnctl qw(:flock);

instead of defining your own constants/



> if (url_param ('action') eq "sign")
>  {
>  sign();
>  }

It would be helpif you followed a more standard code formatting style.  See
perldoc perlstyle


>          print header and print "<center><strong>Viewing Guestbook -
Version
> $version - No guests</strong><hr><a href=\"$homepage\">To
> homepage</a></center>" and exit;

I'm sure you must have been told many times about alternate quoting
mechanisms and using uppercase file handles.

> sub getdate
>  {
>  open (DATE, "date +%D|") or print header and print "Date could not be
> obtained. Please contact your system's administrator.<hr>" and exit;
>  my $date = <DATE>;
>  $date =~ s/\n//g;
>  $date =~ s/\r//g;
>  close (DATE);
>  return ($date);
>  }


Now I find it difficult to believe after all this time, you don't know about
Perl's internal date functions.  Also, why isolate most of the world with an
ambigious date format?

Overall, on the improve, but can/should do much better.




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

Date: Tue, 20 Apr 2004 14:12:24 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: Re: Free source guestbook - unfinished
Message-Id: <c64506$fgo$1@reader2.nmix.net>

yes, I admit it needs work. Thanks you two.
I'll post the revision when it's done.
Later.

--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]




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

Date: 20 Apr 2004 11:06:18 -0700
From: jrodri@HotPop.com (Julian)
Subject: incorrect value for HOSTNAME executed as cron job
Message-Id: <fd6c6323.0404201006.a2fce49@posting.google.com>

Hi.

I have a problem with a script in perl that obtain value of HOSTNAME
environment variable.

!/usr/bin/perl 

# Autoflush
$|=1;

do("/home/sixsl/scripts/constantes.pl");

$lock_dir="/var/dbsync";

$host_actual=$ENV{HOSTNAME};

 ...

When I executed the script manually from the shell it obtain correct
value for hostname (harpo for this case). But when I put the script in
the cron the perl obtain incorrect value, it gets localhost. Cron job
is executed with the same user that I executed the script from the
shell.

The cron daemon is vixie cron. The perl version is 5.8.0. The Linux
box is RedHat 9.0.

Julian.


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

Date: 20 Apr 2004 18:42:24 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: incorrect value for HOSTNAME executed as cron job
Message-Id: <slrnc8arog.nel.xx087@smeagol.ncf.ca>

Julian <jrodri@HotPop.com> wrote:
[...]
>  $host_actual=$ENV{HOSTNAME};
>  
>  ...
>  
>  When I executed the script manually from the shell it obtain correct
>  value for hostname (harpo for this case). But when I put the script in
>  the cron the perl obtain incorrect value, it gets localhost. Cron job
>  is executed with the same user that I executed the script from the
>  shell.

Surprise, you get a different environment in cron than in your
interactive shell.  All you get in a cron environment is HOME, PATH
and a couple of others.  Try running 'env' as a cron job.

You could obtain the hostname by the hostname command, or you could
source your profile before running your script.

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Tue, 20 Apr 2004 20:43:51 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: incorrect value for HOSTNAME executed as cron job
Message-Id: <pkent77tea-825AD5.20435120042004@pth-usenet-02.plus.net>

In article <fd6c6323.0404201006.a2fce49@posting.google.com>,
 jrodri@HotPop.com (Julian) wrote:

> When I executed the script manually from the shell it obtain correct
> value for hostname (harpo for this case). But when I put the script in
> the cron the perl obtain incorrect value, it gets localhost. Cron job
> is executed with the same user that I executed the script from the
> shell.

Cron jobs run in a very, very, impoverished environment. I've never 
known any cron daemon to load the user's .profile (or whatever) before 
executing the crontab entry. The crontab lines are also probably 
executed with the bourne shell, not the user's preferred login shell.

Look in your crond manpage to see what env vars are set - or possibly in 
the headers of the emails that you get from cron (something like 
X-Cron-Env: lines). Failing that, maybe temporarily add a crontab entry 
to run a command like 'env'?

If you want any other env vars set you need to do it yourself - we use a 
wrapper script that sources and sets all the things a job could need 
e.g.:

*/5 * * * * /usr/local/scripts/cron_run /path/to/file arguments

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 20 Apr 2004 18:26:52 GMT
From: Orion93 <orion93@club-internet.fr>
Subject: Need help with table
Message-Id: <Xns94D1D0A66DFF2orion93clubinternetf@194.158.96.17>

Hi!

I use File::Find and actually my script edit all files in a treefiles but 
don't exclude the files with extension define in extension.def.

The line "elsif ($tabext{$ficext} != undef) {}" doesn't work, I am not able 
to say it to compare if the extension of the file find is inclue in 
extension.def to exclude it.

Thanks...

Sophie

Sorry for my english...

Script:
-------

#!/usr/bin/perl -w

use strict;
use warnings;
use diagnostics;
use File::Find;

sub listePages {
my $ext1="c:\\result.txt";
my $direct="c:\\";
open (Desc, "< extension.def");
my %tabext;
while (<Desc>){
$tabext{$_}='1';
}

find(\&accounts, $direct);

sub accounts {
$File::Find::name =~ /(\..*)$/;
my $ficext = $1;
#Pour eliminer les dossiers
if (-d $File::Find::name) {}
#Pour eliminer les fichiers ayant une extension étant dans la liste
elsif ($tabext{$ficext} != undef) {}

else {
open SORTIE,">> $ext1";
print "$File::Find::name \n";
print SORTIE "$File::Find::name \n";
close SORTIE;
}
close Desc;
}
}


File extension.def
---------------------
 .zip
 .doc
 .rtf
 .xls
 .etc


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

Date: Tue, 20 Apr 2004 14:44:10 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Need help with table
Message-Id: <WoydnetdWtTi8hjd4p2dnA@adelphia.com>

Orion93 wrote:

> while (<Desc>){
> $tabext{$_}='1';
> }

When you read a text file like this, the entire line, *including* the
newline character(s) at the end, is read into $_. So the keys in %tabext
are not what you're expecting.

What you need to do here is get rid of the trailing newlines with chomp():

while(<Desc>) {
    chomp;
    $tabext{$_}='1';
}

> Sorry for my english...

Don't be - it's better than that of many "native" speakers. Besides, I
failed (twice) in my attempt to learn French, so I'm in no position to
criticize. ;-)

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 20 Apr 2004 14:46:53 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help with table
Message-Id: <slrnc8avhd.9lr.tadmc@magna.augustmail.com>

Orion93 <orion93@club-internet.fr> wrote:

> I use File::Find and actually my script edit all files in a treefiles but 
> don't exclude the files with extension define in extension.def.
> 
> The line "elsif ($tabext{$ficext} != undef) {}" doesn't work, I am not able 
> to say it to compare if the extension of the file find is inclue in 
> extension.def to exclude it.


> use strict;
> use warnings;


Thank you for your courtesy. We appreciate your respect for other's time.


> sub listePages {
> my $ext1="c:\\result.txt";


It is easier to read and understand if:

   my $ext1 = 'c:\result.txt';  # no doubled backslashes
or
   my $ext1 = 'c:/result.txt';  # no backslashes at all!


> open (Desc, "< extension.def");


You should always, yes *always*, check the return value from open():

   open (Desc, "< extension.def") or die "could not open 'extension.def' $!";


> my %tabext;
> while (<Desc>){


   chomp;   # missing this is likely what is causing the lookup to fail


> $tabext{$_}='1';
> }
> 
> find(\&accounts, $direct);
> 
> sub accounts {
> $File::Find::name =~ /(\..*)$/;
> my $ficext = $1;


You should never use the dollar-digit variables unless you have
first ensured that the match *succeeded*.

   die "no extension on '$_'" unless /(\..*)$/;
   my $ficext = $1;  # $1 is now safe to use


> #Pour eliminer les dossiers
> if (-d $File::Find::name) {}
> #Pour eliminer les fichiers ayant une extension étant dans la liste
> elsif ($tabext{$ficext} != undef) {}


Your hash keys have newlines, $ficext does not have a newline...


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


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

Date: Tue, 20 Apr 2004 18:49:46 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: One question
Message-Id: <ehehc.16435$l75.8850@newsread2.news.atl.earthlink.net>

"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:ang9801or83da8khca7ptnpeikqe4t8u4n@4ax.com...

> enough context, (ii) was referring to the fact you said something to
> the effect that calling your perl program from console would have
> required major hassles in terms of chdir()s et similia IIRC, which is
> utter nonsense IMO, etc.

I am not trying to argue with you about any of these topics.  I simply have
a project goal in mind and am trying to move in that direction as quickly as
possible.  I am trying to get this program up and running and in use by
government scientists and other researchers around the world.

With the version of my Perl earthquake and tornado data evaluation program
which I will probably storing at my Web site for downloads some time today
the Perl code appears to be working fine.  Most of the trouble I have
encountered lately has been with all of the complex data manipulation
operations the program performs.  And you would have those types of problems
no matter what language was used.  At least the Perl programs run fast.
I like their versatility.  And I am amazed at how much data they can easily
handle






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

Date: Tue, 20 Apr 2004 16:44:51 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: One question
Message-Id: <slrnc8b6ej.9qm.tadmc@magna.augustmail.com>

edgrsprj <edgrsprj@ix.netcom.com> wrote:
> "Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
> news:ang9801or83da8khca7ptnpeikqe4t8u4n@4ax.com...
> 
>> enough context, (ii) was referring to the fact you said something to
>> the effect that calling your perl program from console would have
>> required major hassles in terms of chdir()s et similia IIRC, which is
>> utter nonsense IMO, etc.
> 
> I am not trying to argue with you about any of these topics.  


No, you are simply ignoring these topics.


> I simply have
> a project goal in mind and am trying to move in that direction as quickly as
> possible.


No you are not.

If you wanted things to move smoothly you would want to communicate clearly.

No context is communicationg LESS clearly.

Your complete lack of respect for others here have landed you in the killfile.

So long.


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


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

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


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