[24901] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7151 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 17 09:06:48 2004

Date: Fri, 17 Sep 2004 06:05:19 -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           Fri, 17 Sep 2004     Volume: 10 Number: 7151

Today's topics:
    Re: Best place to learn perl? <dani@wimpff.de>
    Re: Best place to learn perl? <shawn.corey@sympatico.ca>
    Re: Can you break Google's secret? <nospam@bigpond.com>
        cp error handling (Urs)
    Re: cp error handling (Anno Siegel)
    Re: cp error handling <spamtrap@dot-app.org>
    Re: cp error handling <someone@example.com>
    Re: define regex in prefix of Text::Balanced functions (Anno Siegel)
        Delete text after a known position in a text file (Oliver S?der)
    Re: Delete text after a known position in a text file <mritty@gmail.com>
    Re: How can I measure web hits from my web browser/end  chris-usenet@roaima.co.uk
    Re: installing perl modules and ports (W i l l)
    Re: killing a "nobody's" process and its group <matrix_calling@yahoo.dot.com>
    Re: multiple assignments with a HoHoA <tore@aursand.no>
    Re: multiple assignments with a HoHoA <matrix_calling@yahoo.dot.com>
    Re: multiple assignments with a HoHoA <shawn.corey@sympatico.ca>
    Re: multiple assignments with a HoHoA <noreply@gunnar.cc>
        Need more efficient use of the substitution operator (Niall Macpherson)
    Re: Need more efficient use of the substitution operato <noreply@gunnar.cc>
    Re: Need more efficient use of the substitution operato (Anno Siegel)
    Re: newbie question <spamtrap@dot-app.org>
    Re: newbie question <noreply@gunnar.cc>
    Re: perl in crontab <spamtrap@dot-app.org>
    Re: perl in crontab <shawn.corey@sympatico.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Sep 2004 15:40:01 +0200
From: Daniel Wimpff <dani@wimpff.de>
Subject: Re: Best place to learn perl?
Message-Id: <414AE931.7070807@wimpff.de>

ft4bredn wrote:
 > Do you know of any books or whatever that break things down like 
that? > Expert explanation man!!

I recommend the book "Programming Perl, 2nd edition" (or a newer if 
exists), O'Reilly & Associates, Inc., Larry Wall, Tom Christiansen & 
Randal L. Schwartz.
There are translations to other languages.

It breaks _all_ ;) the things down and you will understand it, since you 
got Erics explanation.

Daniel



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

Date: Fri, 17 Sep 2004 08:10:01 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Best place to learn perl?
Message-Id: <2uA2d.14173$lb5.1169915@news20.bellglobal.com>

Hi,

Other books:

"Advanced Perl Programming" by Sriram Srinivasan, O'Reilly & Associates, 
Inc. ISBN 1-56592-220-4

"Mastering Algorithms with Perl" by Jon Orwant, Jarkko Hietantiemi & 
John Macdonald, O'Reilly & Associates, Inc. ISBN 1-56592-398-7

	--- Shawn

Daniel Wimpff wrote:

> ft4bredn wrote:
> 
>> Do you know of any books or whatever that break things down like that? 
>> Expert explanation man!!
> 
> 
> I recommend the book "Programming Perl, 2nd edition" (or a newer if 
> exists), O'Reilly & Associates, Inc., Larry Wall, Tom Christiansen & 
> Randal L. Schwartz.
> There are translations to other languages.
> 
> It breaks _all_ ;) the things down and you will understand it, since you 
> got Erics explanation.
> 
> Daniel
> 



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

Date: Fri, 17 Sep 2004 18:19:37 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Can you break Google's secret?
Message-Id: <2qvkqlF13ir0cU1@uni-berlin.de>

Looking wrote:

> The most successful search engine's secret algorithm can be calculated
> from a sandbox/blackbox detection.

Your whole post is nonsense & has little to do with Perl.

gtoomey


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

Date: 17 Sep 2004 03:06:18 -0700
From: urswagner@bluemail.ch (Urs)
Subject: cp error handling
Message-Id: <d817deb6.0409170206.533bc29d@posting.google.com>

Hello

What is the correct formulation of this?

`cp $srcfile $dstfile` || do {
	print "Execution error cp $srcfile, $dstfile\n";	
};

It is always generating "Execution error ..." message.

I would like to have this message only if cp really failed.

Thanks

Urs


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

Date: 17 Sep 2004 11:20:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: cp error handling
Message-Id: <cieh95$4m1$2@mamenchi.zrz.TU-Berlin.DE>

Urs <urswagner@bluemail.ch> wrote in comp.lang.perl.misc:
> Hello
> 
> What is the correct formulation of this?
> 
> `cp $srcfile $dstfile` || do {
> 	print "Execution error cp $srcfile, $dstfile\n";	
> };
> 
> It is always generating "Execution error ..." message.
> 
> I would like to have this message only if cp really failed.

perldoc -f system

Anno


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

Date: Fri, 17 Sep 2004 08:00:06 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: cp error handling
Message-Id: <Et6dnUmPC7laTNfcRVn-rQ@adelphia.com>

Urs wrote:

> What is the correct formulation of this?
> 
> `cp $srcfile $dstfile` || do {
> 	print "Execution error cp $srcfile, $dstfile\n";	
> };
> 
> It is always generating "Execution error ..." message.
> 
> I would like to have this message only if cp really failed.

Backticks capture the output of the command, so the above will fail if 
the cp command produces any output at all. So it will *always* fail if, 
for example, you system's cp is configured to produce verbose output 
(i.e. cp -v) by default.

What you want to use is system(), which returns 0 on success:

(system("cp $srcfile $dstfile") == 0) || do {
	print "Execution error: cp $srcfile, $dstfile\n$!\n";
}

Note the $! variable - When something fails, it's nice to know *why* it 
failed.

sherm--

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


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

Date: Fri, 17 Sep 2004 12:34:30 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: cp error handling
Message-Id: <qRA2d.46198$XP3.38785@edtnps84>

Urs wrote:
> 
> What is the correct formulation of this?
> 
> `cp $srcfile $dstfile` || do {
> 	print "Execution error cp $srcfile, $dstfile\n";	
> };

use File::Copy;

copy( $srcfile, $dstfile ) or die "Execution error copy $srcfile, $dstfile\n";	



John
-- 
use Perl;
program
fulfillment


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

Date: 17 Sep 2004 11:53:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: define regex in prefix of Text::Balanced functions
Message-Id: <ciej8l$747$1@mamenchi.zrz.TU-Berlin.DE>

Wenjie <gokkog@yahoo.com> wrote in comp.lang.perl.misc:
> Hello,
> 
> 
> I have a task to check things within some block in a file:
> ----%<-----
> # this is the block to be analyzed:
> {
> Item one;
> Item two
> } quantity: 3
> ----%<-----
> 
> I want to get:
> a):
> Item one;
> Item two
> b): a) has quantity 3
> 
> 
> Text::Balanced seems to be useful but I have met the problem to 
> specify "prefix":
> 
> use Text::Balanced qw(extract_bracketed);
> use strict;
> 
> my $objfile = shift;
> open (PAT, "< $objfile") or die "couldn't open $objfile for reading: $!\n";
> 
> my $text;
> {
> local $/;
> $text = <PAT>;
> }
> my ($extracted, $remainder) = 
>   extract_bracketed ($text, '{', "What_to_fill_here_?");
> 
> # What to do to extract quantity for the block? 

It is in $remainder (with a leading blank).  What is the problem?

Since you don't say how your text sample might be embedded in other
text, it is impossible to say more.

Anno


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

Date: 17 Sep 2004 02:56:57 -0700
From: osoeder@gmx.de (Oliver S?der)
Subject: Delete text after a known position in a text file
Message-Id: <45c6c8e6.0409170156.2690bed2@posting.google.com>

I want to delete all text after the word "lib\" in a line of a text
field.
IDMLIB=C:\PROGRA~1\Novadigm\Lib\

How can I make $_ all text behind the last back slash? Then I would be
able to do s/$_//. Or is there a better way?


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

Date: Fri, 17 Sep 2004 12:52:59 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Delete text after a known position in a text file
Message-Id: <L6B2d.8294$F75.4435@trndny01>

"Oliver S?der" <osoeder@gmx.de> wrote in message
news:45c6c8e6.0409170156.2690bed2@posting.google.com...
> I want to delete all text after the word "lib\" in a line of a text
> field.
> IDMLIB=C:\PROGRA~1\Novadigm\Lib\
>
> How can I make $_ all text behind the last back slash? Then I would be
> able to do s/$_//. Or is there a better way?

my $string = 'IDMLIB=C:\PROGRA~1\Novadigm\Lib\';
$string =~ s/(lib\\).*/$1/i;

Simply search for the marker, and replace the marker and everything that
follows with just the marker.

Paul Lalli




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

Date: Fri, 17 Sep 2004 09:11:12 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: How can I measure web hits from my web browser/end user perspective....?
Message-Id: <0qiq12-v79.ln1@moldev.cmagroup.co.uk>

Chris Nelson <fimafeng@yahoo.com> wrote:
> I know that for a web server..... there are many ways to measure the
> "hits", when accessing a web page. However, what I need to be able to
> do... is determine that when downloading a web page.... how many
> "hits" comprise that web page.(From an end user perspective)

The more usual approach is to count pages rather than raw hits. To
do that you don't need to know how many hits comprise a page; rather,
you simply assume[1] that each page is represented by a corresponding
single html object and count those.

[1] not necessarily true, but pretty effective unless all your pages
are different framesets

> Am I correct in that an accurate # of hits representing a web page
> could be determined by viewing the source of a web page and adding up
> the files that are listed in that code? Is there a piece of
> code/software that does this?

You're overloading the word "page" here, but I see what you're trying to
say. Your assumption is correct, but it's a hard way of solving the
problem.

> Basically, 
> I have a situation where I need to demonstrate to semi-technical
> people that a single web page can be comprised of many hits.

Create a single instance of a web server, zero out the logs and load a
single page (containing no images or other embedded items). View the log
file and count the entries. Zero out the logs again and load another
page (containing serveral images, etc.). View the log file and count
the entries.

Take particular note of the "referer" [sic] field, which indicates the
referring URL for the item being returned.

> (And in
> my case more importantly..... hits do not in any way directly
> correlate to time spent an individual web page and or site.

View page one, jump to a different web site, return to page two. View
the log files.

None of this is perl related.
Chris


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

Date: 17 Sep 2004 05:25:39 -0700
From: willis3140@yahoo.com (W i l l)
Subject: Re: installing perl modules and ports
Message-Id: <c41c66e9.0409170425.2391b5cb@posting.google.com>

conrads@cox.net (Conrad J. Sabatier) wrote in message news:<arm2d.52378$wu.26675@okepread04>...
> In article <c41c66e9.0409161036.e8c6d56@posting.google.com>,
> W i l l <willis3140@yahoo.com> wrote:
> >
> >
> >I installed some perl modules via CPANPLUS. Now whenever I install
> >anything via ports (or "pkg_add -r anything") I get warnings that look
> >like:
> >
> >pkg_info: package bsdpan-CPANPLUS-0.049 has no origin recorded
> >pkg_info: package bsdpan-Date-Manip-5.42 has no origin recorded
> >pkg_info: package bsdpan-HTML-Parser-3.36 has no origin recorded
> >pkg_info: package bsdpan-HTML-Tagset-3.03 has no origin recorded
> >...
> >
> >And ofcourse the list goes on and on -- at least for ever module I
> >installed outside of the portage system.
>                       ^^^^^^^^^^^^^^^^^^
> 
> SLAP!!!  Where do you think you are, anyway, comp.os.linux.gentoo?
> 
> :-)

forgive me, should I refer to it as "The FreeBSD Ports and Packages Collection"?


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

Date: Fri, 17 Sep 2004 18:25:20 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <GjB2d.27$Ji3.120@news.oracle.com>

Henry Law wrote:
> On 16 Sep 2004 13:01:13 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
> 
> 
>>Henry Law <lawshouse.public@btconnect.com> wrote in
>>news:k19dk0tuu9a5mr2m6qv13tedmidarbpotg@4ax.com: 
>>

[Snip....]

With due respects ...

Let's look at this...

http://www.slightlywarped.com/forumpictures/threadsucks/oracle.jpg

 ...and let helpful people get on with what they do best .. help others 
solve Perl problems (Especially when they have acknowledged their 
misdemeanours up-thread. :)

Regards
Abhinav
P.S. English isnt my 1st language either, and I hope that any words greater 
than 5 characters used above do not have any offensive implications :)


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

Date: Fri, 17 Sep 2004 09:52:11 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <pan.2004.09.17.07.52.11.96319@aursand.no>

On Fri, 17 Sep 2004 11:49:59 +0530, Abhinav wrote:
> my %table;
> $table{'A'}{'B'}=['C','D','E'];
> 
> I now do
> 
> my $val1;
> my $val2;
> my $val2;

I guess you mean '$val3' on that last one.  No need to declare them before
you actually use them;

  my ( $val1, $val2, $val3 ) = ...;

> This :
> 
> ($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
> be undef, 					  #$val3 = ARRAYREF

You need to dereference your array reference;

  my ( $val1, $val2, $val3 ) = @{$table{'A'}{'B'}};


-- 
Tore Aursand <tore@aursand.no>
"When you love someone, all your saved-up wishes start coming out."
 (Elizabeth Bowen)


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

Date: Fri, 17 Sep 2004 16:42:54 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <FPz2d.20$Ji3.76@news.oracle.com>

Tore Aursand wrote:
> On Fri, 17 Sep 2004 11:49:59 +0530, Abhinav wrote:
> 
>>my %table;
>>$table{'A'}{'B'}=['C','D','E'];
>>
>>I now do
>>
>>my $val1;
>>my $val2;
>>my $val2;
> 
> 
> I guess you mean '$val3' on that last one.  No need to declare them before
> you actually use them;
> 

Oops ..yes .. :)

>   my ( $val1, $val2, $val3 ) = ...;
> 
> 
>>This :
>>
>>($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
>>be undef, 					  #$val3 = ARRAYREF
> 
> 
> You need to dereference your array reference;
> 
>   my ( $val1, $val2, $val3 ) = @{$table{'A'}{'B'}};
> 

Thanks ! I skimmed through perldsc before my OP, but I did not grasp it. It 
is much clearer now.

Even the above didn't work initially, thanks to precedence issues as I was 
using the || operator directly after this assignment.

Thanks to everyone for the useful replies

Regards
Abhinav

P.S : The reason for this post was this week's QOTW. While it sounded a bit 
complex, it was actually easy, and newbies might want to go through it. It 
is available at http://perl.plover.com/qotw/r/current.txt (This is quiz #24)

----
--


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

Date: Fri, 17 Sep 2004 08:04:48 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <tpA2d.14172$lb5.1169538@news20.bellglobal.com>

Hi,

($val1, $val2, $val3) = @{ $table{'A'}{'B'} };

	--- Shawn

Abhinav wrote:

> Hi,
> 
> I have a hash variable, %table, which I populate as
> 
> my %table;
> $table{'A'}{'B'}=['C','D','E'];
> 
> I now do
> 
> my $val1;
> my $val2;
> my $val2;
> 
> This :
> 
> ($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
> be undef,                       #$val3 = ARRAYREF
> 
> However, this :
> 
> $val1 =  $table{'A'}{'B'}[0];
> $val2 =  $table{'A'}{'B'}[1];
> $val3 =  $table{'A'}{'B'}[2];   # Does the Right Thing.
> 
> Could someone point out what silly mistake I am committing in the 1st 
> case, and how to rectify it ?
> 
> 
> Thanks
> 
> Abhinav



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

Date: Fri, 17 Sep 2004 14:24:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <2r03dpF13upkqU1@uni-berlin.de>

Abhinav wrote:
> I skimmed through perldsc before my OP, but I did not grasp it.

Of course not. The docs about references and data structures is 
nothing you just "skim"!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 17 Sep 2004 03:19:37 -0700
From: niall.macpherson@moneyline.com (Niall Macpherson)
Subject: Need more efficient use of the substitution operator
Message-Id: <a3376e0d.0409170219.5fdbf5ce@posting.google.com>

I don't use regexp / substitution handling very often and although I
think I have a basic grasp I am having problems with understanding how
to make multiple substitutions of different characters within a
string. I understand the use of appending a 'g' to the command for
multiple substitutions of the same pattern , but the following code
looks as if it could be improved.

I am trying to find the first occurence of anything between a '[' and
a ']'
and return that string 

i.e the following code should print 'STRING'. It appears to work but
seems a bit long winded. Is there a better way of doing it ?

use strict;
use warnings;
use diagnostics;

sub GetString
{
	my ($teststring) = @_;
	
	if ($teststring =~ /\[.*\]/)
	{
		my $match  = $&;
		$match =~ s/\[//;
		$match =~ s/\]//;
		return($match);
	}
	else
	{
		return("");
	}
}

my $input = " foo [STRING] bar ";
my $output = GetString($input);
print "Result = '$output'"; 

Thanks


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

Date: Fri, 17 Sep 2004 12:45:18 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Need more efficient use of the substitution operator
Message-Id: <2qvtjpF151obkU1@uni-berlin.de>

Niall Macpherson wrote:
> I don't use regexp / substitution handling very often and although
> I think I have a basic grasp I am having problems with
> understanding how to make multiple substitutions of different
> characters within a string. I understand the use of appending a 'g'
> to the command for multiple substitutions of the same pattern , but
> the following code looks as if it could be improved.
> 
> I am trying to find the first occurence of anything between a '['
> and a ']' and return that string

If you are trying to *find* something, it's not substitution you
should do, but you'd rather use the m// (matching) operator with
capturing parentheses (see "perldoc perlop").

> i.e the following code should print 'STRING'. It appears to work
> but seems a bit long winded. Is there a better way of doing it ?

<code snipped>

Indeed.

     my $input = " foo [STRING] bar ";
     print "Result = '", $input =~ /\[(.*?)\]/, "'\n";

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 17 Sep 2004 11:17:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need more efficient use of the substitution operator
Message-Id: <cieh4j$4m1$1@mamenchi.zrz.TU-Berlin.DE>

Niall Macpherson <niall.macpherson@moneyline.com> wrote in comp.lang.perl.misc:
> I don't use regexp / substitution handling very often and although I
> think I have a basic grasp I am having problems with understanding how
> to make multiple substitutions of different characters within a
> string. I understand the use of appending a 'g' to the command for
> multiple substitutions of the same pattern , but the following code
> looks as if it could be improved.
> 
> I am trying to find the first occurence of anything between a '[' and
> a ']'
> and return that string 

That is, you want to match part of a string and return the result.
That is what capturing parentheses are for.

> i.e the following code should print 'STRING'. It appears to work but
> seems a bit long winded. Is there a better way of doing it ?

It doesn't even do exactly what you want.  Test it with
" foo [STRING] [A-LING] bar ".

> use strict;
> use warnings;
> use diagnostics;
> 
> sub GetString
> {
> 	my ($teststring) = @_;
> 	
> 	if ($teststring =~ /\[.*\]/)

This matches everything from the first opening "[" to the last closing
"]".  To catch only the first pair, make the /.*/ non-greedy:

    /\[.*?\]/

> 	{
> 		my $match  = $&;
> 		$match =~ s/\[//;
> 		$match =~ s/\]//;
> 		return($match);

You could have returned the substring of $match from the second to
the next-to-last character, instead of deleting the brackets:

    return substr( $match, 1, -1);

But see below.

> 	}
> 	else
> 	{
> 		return("");

It would be wiser to return nothing instead of an empty string in
case of failure.  An empty string is a legitimate return value
for an empty "[]".  Just

    return;

> 	}
> }
> 
> my $input = " foo [STRING] bar ";
> my $output = GetString($input);
> print "Result = '$output'"; 

The use of $& to capture the match is still supported, but there are
better ways.  Use capturing parentheses to extract exactly the part
of the match you want.  That way, you get the content of the "[...]"
directly:

    my ( $match ) = $teststring =~ /\[(.*?)\]/;

That is all.  Putting it together:

    sub GetString {
        my $teststring = shift;
        my ( $match) = $teststring =~ /\[(.*?)\]/ or return;
        $match;
    }

or even

    sub GetString { ( shift =~ /\[(.*?)\]/)[ 0] }

Anno


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

Date: Fri, 17 Sep 2004 07:27:22 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: newbie question
Message-Id: <TpKdnXqViZ6GV9fcRVn-pg@adelphia.com>

krakle wrote:

> I disagree. I believe  ...

It's not a matter of opinion or belief. Your output was plain text, and 
you labeled it as HTML. You were wrong.

sherm--

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


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

Date: Fri, 17 Sep 2004 14:40:00 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie question
Message-Id: <2r04atF14svn0U1@uni-berlin.de>

Sherm Pendley wrote:
> krakle wrote:
>> I disagree. I believe  ...
> 
> It's not a matter of opinion or belief.

How about reality? Have you tried to run a CGI script with text/plain 
from IE? That's what I thought.

For that reason, I *never* use text/plain in CGI scripts other than 
those I write for my own use only. Instead, when the script actually 
outputs plain text, I use e.g. the <pre> tag.

> Your output was plain text, and you labeled it as HTML.

Maybe true, but...

> You were wrong.

Irrelevant in this case. ;-)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 17 Sep 2004 07:32:44 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: perl in crontab
Message-Id: <zLqdnUFU3rbAVtfcRVn-tA@adelphia.com>

news.hinet.net wrote:

> This test can work when i run it anywhere.
> But the chdir seem does not work when i set it in crontab??

Like Sam said - check for errors and print error messages.

Also, look at the man pages for cron and crontab. Cron jobs run under a 
limited environment - most notably, the PATH variable is not likely the 
same as it is when you log into a shell.

sherm--

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


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

Date: Fri, 17 Sep 2004 08:01:40 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: perl in crontab
Message-Id: <dmA2d.14171$lb5.1169095@news20.bellglobal.com>

Hi,

Two possible reasons. 1) Permissions: the crontab is running under a 
different user that cannot access the files. 2) No profile: cron does 
not run the user's .profile (or .cshrc and .login for csh) when it runs. 
  Try using the full path for tar, system( "/usr/bin/tar ...

news.hinet.net wrote:

> This test can work when i run it anywhere.
> But the chdir seem does not work when i set it in crontab??
> ==============================================
> #!/usr/bin/perl
> 
> chdir("/usr/local/admin/dir");
> system("tar zcvf test.tgz *");
> 
> 



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

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


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