Re: Perl Script as a Cron Job

2006-10-19 Thread Mazhar

On 10/12/06, Paul [EMAIL PROTECTED] wrote:



On Wed, October 11, 2006 7:03 am, Mazhar wrote:
 Dear All,

 My Code is to ping a range of IP reading from a text file and if they
are
 not reachable then just write the IP's to  a file. Regarding permissions
i
 am running the same script using root previliges and i am able to run
the
 script maually but it is failing if i write the script in cron like one
 below,
 10 * * * * /scripts/.pl

I usually use perl just before it like this:

10 * * * * perl /scripts/.pl


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Dear,

No even the above help is npt useful in running the cron job

Regards
Mazhar


Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

Dear All,

My Code is to ping a range of IP reading from a text file and if they are
not reachable then just write the IP's to  a file. Regarding permissions i
am running the same script using root previliges and i am able to run the
script maually but it is failing if i write the script in cron like one
below,
10 * * * * /scripts/.pl

Can u all please help on the above

Regards
Mazhar


On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:


On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:

 I tried with the below and made my script as executable with chmod
command
 but the same is not running every 10 minutes.

Once you have worked out your crontab syntax, almost all cron problems are
due
to permissions or environment.

 Need your help

Since you have provided no information whatsoever on how your script is
failing it is hard to say more than that.

--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

The Answers are

1. Is /scripts/.pl the full path name?
Yes the above is the correct path of the script : when i run perl
/scripts/xxx.pl it runs fine
2. Does your script have execute permissions
Yes it has execute permissions (i changed it chmod +x for the code file)
3. Does the shebang line indicate the full path to the perl binary?
Can u explain me what does the above signify

Regards
Mazhar



On 10/11/06, Owen Cook [EMAIL PROTECTED] wrote:


On Wed, Oct 11, 2006 at 03:03:12PM +0400, Mazhar wrote:
 Dear All,

 My Code is to ping a range of IP reading from a text file and if they
are
 not reachable then just write the IP's to  a file. Regarding permissions
i
 am running the same script using root previliges and i am able to run
the
 script maually but it is failing if i write the script in cron like one
 below,
 10 * * * * /scripts/.pl

 Can u all please help on the above



1. Is /scripts/.pl the full path name?
2. Does your script have execute permissions
3. Does the shebang line indicate the full path to the perl binary?



Owen





 Regards
 Mazhar


 On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:
 
 On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:
 
  I tried with the below and made my script as executable with chmod
 command
  but the same is not running every 10 minutes.
 
 Once you have worked out your crontab syntax, almost all cron problems
are
 due
 to permissions or environment.
 
  Need your help
 
 Since you have provided no information whatsoever on how your script is
 failing it is hard to say more than that.
 
 --
 Paul Johnson - [EMAIL PROTECTED]
 http://www.pjcj.net
 

--



Re: Perl Script as a Cron Job

2006-10-11 Thread Owen Cook
On Wed, Oct 11, 2006 at 03:03:12PM +0400, Mazhar wrote:
 Dear All,
 
 My Code is to ping a range of IP reading from a text file and if they are
 not reachable then just write the IP's to  a file. Regarding permissions i
 am running the same script using root previliges and i am able to run the
 script maually but it is failing if i write the script in cron like one
 below,
 10 * * * * /scripts/.pl
 
 Can u all please help on the above



1. Is /scripts/.pl the full path name?
2. Does your script have execute permissions
3. Does the shebang line indicate the full path to the perl binary?



Owen




 
 Regards
 Mazhar
 
 
 On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:
 
 On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:
 
  I tried with the below and made my script as executable with chmod
 command
  but the same is not running every 10 minutes.
 
 Once you have worked out your crontab syntax, almost all cron problems are
 due
 to permissions or environment.
 
  Need your help
 
 Since you have provided no information whatsoever on how your script is
 failing it is hard to say more than that.
 
 --
 Paul Johnson - [EMAIL PROTECTED]
 http://www.pjcj.net
 

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

I have set the Shebang in my code to the below

#!/usr/bin/perl

and below is top of my code below,
---

#!/usr/bin/perl

use strict;
use warnings;
use Net::Ping;

my $file_name='hostnames.txt';
my $line;
my @host_array;

`rm pingnotif*.*`;

`touch alive.log`;
_-

Regards
Mazhar


On 10/11/06, Steve Finkelstein [EMAIL PROTECTED] wrote:


What #3 means, is your shebang should contain the full path to perl. This
could be something similar to:

#!/usr/bin/perl
#!/usr/local/bin/perl

If you have your shebang set to:

#!perl

Your cron environment might not be able to find the PATH to the binary.

-- Steve

On 10/11/06, Mazhar [EMAIL PROTECTED] wrote:

 The Answers are

 1. Is /scripts/.pl the full path name?
 Yes the above is the correct path of the script : when i run perl
 /scripts/xxx.pl it runs fine
 2. Does your script have execute permissions
 Yes it has execute permissions (i changed it chmod +x for the code file)

 3. Does the shebang line indicate the full path to the perl binary?
 Can u explain me what does the above signify

 Regards
 Mazhar



 On 10/11/06, Owen Cook  [EMAIL PROTECTED] wrote:
 
  On Wed, Oct 11, 2006 at 03:03:12PM +0400, Mazhar wrote:
   Dear All,
  
   My Code is to ping a range of IP reading from a text file and if
 they
  are
   not reachable then just write the IP's to  a file. Regarding
 permissions
  i
   am running the same script using root previliges and i am able to
 run
  the
   script maually but it is failing if i write the script in cron like
 one
   below,
   10 * * * * /scripts/.pl
  
   Can u all please help on the above
 
 
 
  1. Is /scripts/.pl the full path name?
  2. Does your script have execute permissions
  3. Does the shebang line indicate the full path to the perl binary?
 
 
 
  Owen
 
 
 
 
  
   Regards
   Mazhar
  
  
   On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:
   
   On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:
   
I tried with the below and made my script as executable with
 chmod
   command
but the same is not running every 10 minutes.
   
   Once you have worked out your crontab syntax, almost all cron
 problems
  are
   due
   to permissions or environment.
   
Need your help
   
   Since you have provided no information whatsoever on how your
 script is
   failing it is hard to say more than that.
   
   --
   Paul Johnson - [EMAIL PROTECTED]
   http://www.pjcj.net
   
 
  --
 





Re: Perl Script as a Cron Job

2006-10-11 Thread Bjørge Solli
This is the last top-posted email from you that I will answer..
Please learn how to quote properly!

On Wednesday 11 October 2006 13:14, Mazhar wrote:
 1. Is /scripts/.pl the full path name?
 Yes the above is the correct path of the script : when i run perl
 /scripts/xxx.pl it runs fine

So this is how you run it from command:?
perl /scripts/xxx.pl

What happens if you try this:
/scripts/xxx.pl

 2. Does your script have execute permissions
 Yes it has execute permissions (i changed it chmod +x for the code file)

what is the output of
ls -l /scripts/xxx.pl

 3. Does the shebang line indicate the full path to the perl binary?
 Can u explain me what does the above signify

What is the first line in your script?
It *should* look like this:
#!/usr/bin/perl
or similar.

Make sure you also have at the top of your script:
use strict;
use warnings;

Then give us the *whole* error message (the whole output if it is not too 
long).

Regards
Bjørge

 Regards
 Mazhar

 On 10/11/06, Owen Cook [EMAIL PROTECTED] wrote:
  On Wed, Oct 11, 2006 at 03:03:12PM +0400, Mazhar wrote:
   Dear All,
  
   My Code is to ping a range of IP reading from a text file and if they
 
  are
 
   not reachable then just write the IP's to  a file. Regarding
   permissions
 
  i
 
   am running the same script using root previliges and i am able to run
 
  the
 
   script maually but it is failing if i write the script in cron like one
   below,
   10 * * * * /scripts/.pl
  
   Can u all please help on the above
 
  1. Is /scripts/.pl the full path name?
  2. Does your script have execute permissions
  3. Does the shebang line indicate the full path to the perl binary?
 
 
 
  Owen
 
   Regards
   Mazhar
  
   On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:
   On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:
I tried with the below and made my script as executable with chmod
   
   command
   
but the same is not running every 10 minutes.
   
   Once you have worked out your crontab syntax, almost all cron problems
 
  are
 
   due
   to permissions or environment.
   
Need your help
   
   Since you have provided no information whatsoever on how your script
is failing it is hard to say more than that.
   
   --
   Paul Johnson - [EMAIL PROTECTED]
   http://www.pjcj.net
 
  --

-- 
Bjørge Solli - Office:+47 55205847
Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47
Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no
Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Perl Script as a Cron Job

2006-10-11 Thread Thomas Bätzler
Mazhar [EMAIL PROTECTED] wrote:
 My Code is to ping a range of IP reading from a text file and 
 if they are not reachable then just write the IP's to  a 
 file. Regarding permissions i am running the same script 
 using root previliges and i am able to run the script maually 
 but it is failing if i write the script in cron like one 
 below, 10 * * * * /scripts/.pl
 
 Can u all please help on the above

How do you ping the remote hosts? If you script runs on the
command line but not from cron, then it's usually a safe bet
that it's due to the environment and especially the PATH
variable. Either make sure to set up the PATH properly or
run commands using their fully qualified path names.

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

Sorry Solli,

Below is the output what u asked for,

1. If i run the code /scripts/xxx.pl i get the below error...


interpreter /usr/bin/perl not found

  sh: /scripts/xxx.pl:  not found.

2. The first line in the code is below (i have added the Shepang Value)
#!/usr/bin/perl

I did not get the meaning of (Quote properly)

Regards
Mazhar


On 10/11/06, Bjørge Solli [EMAIL PROTECTED] wrote:


This is the last top-posted email from you that I will answer..
Please learn how to quote properly!

On Wednesday 11 October 2006 13:14, Mazhar wrote:
 1. Is /scripts/.pl the full path name?
 Yes the above is the correct path of the script : when i run perl
 /scripts/xxx.pl it runs fine

So this is how you run it from command:?
perl /scripts/xxx.pl

What happens if you try this:
/scripts/xxx.pl

 2. Does your script have execute permissions
 Yes it has execute permissions (i changed it chmod +x for the code file)

what is the output of
ls -l /scripts/xxx.pl

 3. Does the shebang line indicate the full path to the perl binary?
 Can u explain me what does the above signify

What is the first line in your script?
It *should* look like this:
#!/usr/bin/perl
or similar.

Make sure you also have at the top of your script:
use strict;
use warnings;

Then give us the *whole* error message (the whole output if it is not too
long).

Regards
Bjørge

 Regards
 Mazhar

 On 10/11/06, Owen Cook [EMAIL PROTECTED] wrote:
  On Wed, Oct 11, 2006 at 03:03:12PM +0400, Mazhar wrote:
   Dear All,
  
   My Code is to ping a range of IP reading from a text file and if
they
 
  are
 
   not reachable then just write the IP's to  a file. Regarding
   permissions
 
  i
 
   am running the same script using root previliges and i am able to
run
 
  the
 
   script maually but it is failing if i write the script in cron like
one
   below,
   10 * * * * /scripts/.pl
  
   Can u all please help on the above
 
  1. Is /scripts/.pl the full path name?
  2. Does your script have execute permissions
  3. Does the shebang line indicate the full path to the perl binary?
 
 
 
  Owen
 
   Regards
   Mazhar
  
   On 10/9/06, Paul Johnson [EMAIL PROTECTED] wrote:
   On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:
I tried with the below and made my script as executable with
chmod
   
   command
   
but the same is not running every 10 minutes.
   
   Once you have worked out your crontab syntax, almost all cron
problems
 
  are
 
   due
   to permissions or environment.
   
Need your help
   
   Since you have provided no information whatsoever on how your
script
is failing it is hard to say more than that.
   
   --
   Paul Johnson - [EMAIL PROTECTED]
   http://www.pjcj.net
 
  --

--
Bjørge Solli - Office:+47 55205847
Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47
Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no
Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

Dear Thomas,

I am running PING from the package Net, can u tell me where can i find the
logs of cron jobs as because with that i will be able to check the
possibility of not running the script, please

Regards
Mazhar


On 10/11/06, Thomas Bätzler [EMAIL PROTECTED] wrote:


Mazhar [EMAIL PROTECTED] wrote:
 My Code is to ping a range of IP reading from a text file and
 if they are not reachable then just write the IP's to  a
 file. Regarding permissions i am running the same script
 using root previliges and i am able to run the script maually
 but it is failing if i write the script in cron like one
 below, 10 * * * * /scripts/.pl

 Can u all please help on the above

How do you ping the remote hosts? If you script runs on the
command line but not from cron, then it's usually a safe bet
that it's due to the environment and especially the PATH
variable. Either make sure to set up the PATH properly or
run commands using their fully qualified path names.

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





Re: Perl Script as a Cron Job

2006-10-11 Thread Bjørge Solli
On Wednesday 11 October 2006 13:35, Mazhar wrote:
 I did not get the meaning of (Quote properly)

http://www.xs4all.nl/~hanb/documents/quotingguide.html

When it ways usenet, think email-lists too.

-- 
Bjørge Solli - Office:+47 55205847
Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47
Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no
Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Paul Johnson
On Wed, Oct 11, 2006 at 03:35:03PM +0400, Mazhar wrote:

 1. If i run the code /scripts/xxx.pl i get the below error...
 
 interpreter /usr/bin/perl not found
   sh: /scripts/xxx.pl:  not found.

So it would appear that this is not where perl is found on your system.
You need to put the correct path to perl on the shebang line.  Probably
which perl will tell you that.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

On 10/11/06, Paul Johnson [EMAIL PROTECTED] wrote:


On Wed, Oct 11, 2006 at 03:35:03PM +0400, Mazhar wrote:

 1. If i run the code /scripts/xxx.pl i get the below error...

 interpreter /usr/bin/perl not found
   sh: /scripts/xxx.pl:  not found.

So it would appear that this is not where perl is found on your system.
You need to put the correct path to perl on the shebang line.  Probably
which perl will tell you that.




Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Hi Paul,

i have added /usr/bin/perl in my code and the ouptput of the command which
perl is also /usr/bin/perl

Regards
Mazhar


Re: Perl Script as a Cron Job

2006-10-11 Thread Paul Johnson
On Wed, Oct 11, 2006 at 04:18:04PM +0400, Mazhar wrote:

 On Wed, Oct 11, 2006 at 03:35:03PM +0400, Mazhar wrote:
 
  1. If i run the code /scripts/xxx.pl i get the below error...
 
  interpreter /usr/bin/perl not found
sh: /scripts/xxx.pl:  not found.

 i have added /usr/bin/perl in my code and the ouptput of the command which
 perl is also /usr/bin/perl

Then my next guess is that you have a CR at the end of the line.  Perhaps the
whole file is in dos format?  Running dos2unix will fix that, if it is the
problem.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

On 10/11/06, Paul Johnson [EMAIL PROTECTED] wrote:


On Wed, Oct 11, 2006 at 04:18:04PM +0400, Mazhar wrote:

 On Wed, Oct 11, 2006 at 03:35:03PM +0400, Mazhar wrote:
 
  1. If i run the code /scripts/xxx.pl i get the below error...
 
  interpreter /usr/bin/perl not found
sh: /scripts/xxx.pl:  not found.

 i have added /usr/bin/perl in my code and the ouptput of the command
which
 perl is also /usr/bin/perl

Then my next guess is that you have a CR at the end of the line.  Perhaps
the
whole file is in dos format?  Running dos2unix will fix that, if it is the
problem.

--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



Paul,

I have created the file in Windows and have pasted the entries in HP-UNIX (i
mean copied). I cannot find the command dos2unix in HP UX.

Thanks in Advance

Regards
Mazhar


Re: Perl Script as a Cron Job

2006-10-11 Thread Ken Foskey
On Wed, 2006-10-11 at 16:45 +0400, Mazhar wrote:

 I have created the file in Windows and have pasted the entries in HP-UNIX (i
 mean copied). I cannot find the command dos2unix in HP UX.
 

easy check, change command line to this:

#!/usr/bin/perl -w

to strip the carriage returns try something like this:

tr -d '\r'  perl.pl  perl.pl.new

or for a simple perl way of doing it.  (Untested, reasonably sure it is
right)

#!/usr/bin/perl -w
while(  ) {
s/\r//;
print;
}



-- 
Ken Foskey
FOSS developer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

On 10/11/06, Ken Foskey [EMAIL PROTECTED] wrote:


On Wed, 2006-10-11 at 16:45 +0400, Mazhar wrote:

 I have created the file in Windows and have pasted the entries in
HP-UNIX (i
 mean copied). I cannot find the command dos2unix in HP UX.


easy check, change command line to this:

#!/usr/bin/perl -w

to strip the carriage returns try something like this:

tr -d '\r'  perl.pl  perl.pl.new

or for a simple perl way of doing it.  (Untested, reasonably sure it is
right)

#!/usr/bin/perl -w
while(  ) {
   s/\r//;
   print;
}



--
Ken Foskey
FOSS developer


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Hi Ken,


From the help above i created a new perl code and i was successfull in

running the code by typing the command /scripts/newxxx.pl but the same is
not executed by cron i have the cron entry as below

10 * * * * /scripts/newxxx.pl

Thanks in Advance

Regards
Mazhar


Re: Perl Script as a Cron Job

2006-10-11 Thread Beginner
On 11 Oct 2006 at 17:14, Mazhar wrote:

 From the help above i created a new perl code and i was successfull in
 running the code by typing the command /scripts/newxxx.pl but the same is
 not executed by cron i have the cron entry as below
 
  10 * * * * /scripts/newxxx.pl


This as to be the longest running thread since the great Good 
answer/bad answer debate.

So Mazhar:

1) In who's crontab file have you put this entry?
2) Does this user exist in cron-allow?
3) Do you need to HUP crond to get the cron -rescheduled?
4) Have you any access to the cron log, if so what does that say?
5) Try printing out the environment variables at the start of the 
script incase there is something restricting the job. Something like 
the bit below (untested).

foreach my $k (%ENV) {
print $k - $ENV{$k}\n;
}


Is there any any output from the command, either from cron or from 
the command line? Can we see a sample please and the output from the 
above.
Thanx.
Dp.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

On 10/11/06, Beginner [EMAIL PROTECTED] wrote:
On 11 Oct 2006 at 17:14, Mazhar wrote: From the help above i created a new perl code and i was successfull in
 running the code by typing the command /scripts/newxxx.pl but the same is not executed by cron i have the cron entry as below10 * * * * /scripts/newxxx.plThis as to be the longest running thread since the great Good
answer/bad answer debate.So Mazhar:1) In who's crontab file have you put this entry?2) Does this user exist in cron-allow?3) Do you need to HUP crond to get the cron -rescheduled?4) Have you any access to the cron log, if so what does that say?
5) Try printing out the environment variables at the start of thescript incase there is something restricting the job. Something likethe bit below (untested).foreach my $k (%ENV) { print $k - $ENV{$k}\n;
}Is there any any output from the command, either from cron or fromthe command line? Can we see a sample please and the output from theabove.Thanx.Dp.--To unsubscribe, e-mail: 
[EMAIL PROTECTED]For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
Dear DP,

Your answers to the questions above are here as follows,

1) In who's crontab file have you put this entry?
 In Root Login2) Does this user exist in cron-allow?
Yes 3) Do you need to HUP crond to get the cron -rescheduled?
No4) Have you any access to the cron log, if so what does that say?
How can i found the log file for cron job

5) Try printing out the environment variables at the start of thescript incase there is something restricting the job. Something likethe bit below (untested).foreach my $k (%ENV) { print $k - $ENV{$k}\n;
}Attached is the file containing the output of the above script (op.log)

Regards
Mazhar


op.log
Description: Binary data
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


RE: Perl Script as a Cron Job

2006-10-11 Thread Jason Wozniak
Here is what I use for a perl script I use to restart the oracle
listener if it goes down, to set the oracle environment.

 

00,10,20,30,40,50 * * * * (. $HOME/.bash_profile;
$HOME/hdpjfw_scripts/dbping.pl) $HOME/spool/db_ping.out 21

 



From: Mazhar [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 11, 2006 11:05 AM
To: Beginner
Cc: beginners perl
Subject: Re: Perl Script as a Cron Job

 

 

On 10/11/06, Beginner [EMAIL PROTECTED] wrote: 

On 11 Oct 2006 at 17:14, Mazhar wrote:

 From the help above i created a new perl code and i was successfull in

 running the code by typing the command /scripts/newxxx.pl but the same
is
 not executed by cron i have the cron entry as below

  10 * * * * /scripts/newxxx.pl


This as to be the longest running thread since the great Good 
answer/bad answer debate.

So Mazhar:

1) In who's crontab file have you put this entry?
2) Does this user exist in cron-allow?
3) Do you need to HUP crond to get the cron -rescheduled?
4) Have you any access to the cron log, if so what does that say? 
5) Try printing out the environment variables at the start of the
script incase there is something restricting the job. Something like
the bit below (untested).

foreach my $k (%ENV) {
   print $k - $ENV{$k}\n; 
}


Is there any any output from the command, either from cron or from
the command line? Can we see a sample please and the output from the
above.
Thanx.
Dp.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/ 
http://learn.perl.org/first-response




Dear DP,

 

Your answers to the questions above are here as follows,

 

1) In who's crontab file have you put this entry?

  In Root Login
2) Does this user exist in cron-allow?

 Yes 
3) Do you need to HUP crond to get the cron -rescheduled?

No
4) Have you any access to the cron log, if so what does that say?

How can i found the log file for cron job

 

5) Try printing out the environment variables at the start of the
script incase there is something restricting the job. Something like
the bit below (untested).

foreach my $k (%ENV) {
   print $k - $ENV{$k}\n; 
}

Attached is the file containing the output of the above script (op.log)

 

Regards

Mazhar



Re: Perl Script as a Cron Job

2006-10-11 Thread Mazhar

On 10/11/06, Jason Wozniak [EMAIL PROTECTED] wrote:


 Here is what I use for a perl script I use to restart the oracle listener
if it goes down, to set the oracle environment.



00,10,20,30,40,50 * * * * (. $HOME/.bash_profile;
$HOME/hdpjfw_scripts/dbping.pl) $HOME/spool/db_ping.out 21


 --




Hi Jason
Can u help me in providing the path where the cron jobs write to a log, as i
can debug more seeing the same in the log file

Regards
Mazhar



 *From:* Mazhar [mailto:[EMAIL PROTECTED]

*Sent:* Wednesday, October 11, 2006 11:05 AM
*To:* Beginner
*Cc:* beginners perl
*Subject:* Re: Perl Script as a Cron Job





On 10/11/06, *Beginner* [EMAIL PROTECTED] wrote:

On 11 Oct 2006 at 17:14, Mazhar wrote:

 From the help above i created a new perl code and i was successfull in
 running the code by typing the command /scripts/newxxx.pl but the same
is
 not executed by cron i have the cron entry as below

  10 * * * * /scripts/newxxx.pl


This as to be the longest running thread since the great Good
answer/bad answer debate.

So Mazhar:

1) In who's crontab file have you put this entry?
2) Does this user exist in cron-allow?
3) Do you need to HUP crond to get the cron -rescheduled?
4) Have you any access to the cron log, if so what does that say?
5) Try printing out the environment variables at the start of the
script incase there is something restricting the job. Something like
the bit below (untested).

foreach my $k (%ENV) {
   print $k - $ENV{$k}\n;
}


Is there any any output from the command, either from cron or from
the command line? Can we see a sample please and the output from the
above.
Thanx.
Dp.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response


Dear DP,



Your answers to the questions above are here as follows,



1) In who's crontab file have you put this entry?

*  In Root Login*
2) Does this user exist in cron-allow?

 *Yes*
3) Do you need to HUP crond to get the cron -rescheduled?

*No*
4) Have you any access to the cron log, if so what does that say?

*How can i found the log file for cron job*



5) Try printing out the environment variables at the start of the
script incase there is something restricting the job. Something like
the bit below (untested).

foreach my $k (%ENV) {
   print $k - $ENV{$k}\n;
}

*Attached is the file containing the output of the above script (op.log)*



Regards

Mazhar



Re: Perl Script as a Cron Job

2006-10-11 Thread Stuart Adams

Mazhar,
The cron log is most likely written to /var/log/cron

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-11 Thread Paul

On Wed, October 11, 2006 7:03 am, Mazhar wrote:
 Dear All,

 My Code is to ping a range of IP reading from a text file and if they are
 not reachable then just write the IP's to  a file. Regarding permissions i
 am running the same script using root previliges and i am able to run the
 script maually but it is failing if i write the script in cron like one
 below,
 10 * * * * /scripts/.pl

I usually use perl just before it like this:

10 * * * * perl /scripts/.pl


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-09 Thread Bjørge Solli
On Monday 09 October 2006 11:03, Mazhar wrote:
 I have prepared a script that is to be run as a cron job every 10 minutes,
 i have added the same in cron as below,

 *0,10,20,30,40,50 * * * * /scripts/x.pl*

You have too many stars, remove the leading and trailing stars, or try:
*/10 * * * * /path/script.pl

http://en.wikipedia.org/wiki/Crontab
http://www.computerhope.com/unix/ucrontab.htm

-- 
Bjørge Solli - Office:+47 55205847
Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47
Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no
Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-09 Thread Jeff Pang


I have prepared a script that is to be run as a cron job every 10 minutes, i
have added the same in cron as below,

*0,10,20,30,40,50 * * * * /scripts/x.pl*

But the above is not running properly, should i add something in the code.


Try this:

*/10 * * * * /scritps/xxx.pl

The xxx.pl should be executable.



--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Script as a Cron Job

2006-10-09 Thread Mazhar

When i add the entry as specified i get the below error (i.e) */10 * * * *
/scritps/xxx.pl in cron

*crontab: error on previous line; unexpected character found in line.*

Regards
Mazhar


On 10/9/06, Jeff Pang [EMAIL PROTECTED] wrote:




I have prepared a script that is to be run as a cron job every 10
minutes, i
have added the same in cron as below,

*0,10,20,30,40,50 * * * * /scripts/x.pl*

But the above is not running properly, should i add something in the
code.


Try this:

*/10 * * * * /scritps/xxx.pl

The xxx.pl should be executable.



--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





Re: Perl Script as a Cron Job

2006-10-09 Thread Mazhar

I tried with the below and made my script as executable with chmod command
but the same is not running every 10 minutes.

Need your help

Regards
Mazhar


On 10/9/06, Hal Wigoda [EMAIL PROTECTED] wrote:


get rid of the /.


On Oct 9, 2006, at 5:55 AM, Mazhar wrote:

 When i add the entry as specified i get the below error (i.e) */10
 * * * *
 /scritps/xxx.pl in cron

 *crontab: error on previous line; unexpected character found in line.*

 Regards
 Mazhar


 On 10/9/06, Jeff Pang [EMAIL PROTECTED] wrote:


 
 I have prepared a script that is to be run as a cron job every 10
 minutes, i
 have added the same in cron as below,
 
 *0,10,20,30,40,50 * * * * /scripts/x.pl*
 
 But the above is not running properly, should i add something in the
 code.
 

 Try this:

 */10 * * * * /scritps/xxx.pl

 The xxx.pl should be executable.



 --
 Jeff Pang
 NetEase AntiSpam Team
 http://corp.netease.com

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response







Re: Perl Script as a Cron Job

2006-10-09 Thread Paul Johnson
On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:

 I tried with the below and made my script as executable with chmod command
 but the same is not running every 10 minutes.

Once you have worked out your crontab syntax, almost all cron problems are due
to permissions or environment.

 Need your help

Since you have provided no information whatsoever on how your script is
failing it is hard to say more than that.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response