getting the File size of image URL

2006-10-11 Thread Anish Kumar K.
Is it possible to calculate the File SIZE which is from HTTP. i.e if I 
wanted to know


file size of http://www.yahoo.com/images/a.gif from PERL..

Thanks
Anish


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.2/471 - Release Date: 10/10/2006


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




need to parse and verify certain content..

2006-10-11 Thread Vishwanath Chitnis

hi,

i need to parse the content on a page (which are basically headers ) and
verify certain content is returned or not by my server . i am using IE
automation i tried using
Content();
VerifyText($string, [iflags])..but getting Undefined subroutine
main::Content called at main.pl line 35. this error..any ideas how this
can be done..?
is there any other way other than above mentioned to do this?

thanks in advance
vish


RE: need to parse and verify certain content..

2006-10-11 Thread Charles K. Clarkson
Vishwanath Chitnis wrote:

: is there any other way other than above mentioned to do this?

How can we possibly tell with only those lines?

Show more code. Something we can run that will illustrate
your problem.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.


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




RE: getting the File size of image URL

2006-10-11 Thread Thomas Bätzler
Anish Kumar K. [EMAIL PROTECTED] asked:
 Is it possible to calculate the File SIZE which is from HTTP. 
 i.e if I wanted to know
 
 file size of http://www.yahoo.com/images/a.gif from PERL..

Send a HEAD request for the URI and look at the
Content-Length header of the response object:

#!/usr/bin/perl -w

use strict;
use LWP::UserAgent;

my $url = 'http://us.i1.yimg.com/us.yimg.com/i/yahoo.gif';

my $ua = new LWP::UserAgent(timeout = 60);

my $response = $ua-head( $url );

if( $response-is_success ){
  print 'The image size is ' . $response-header('Content-Length') .  
bytes.\n;
} else {
  die 'The request was unsuccessful: ' . $response-status_line;
}

__END__

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: getting the File size of image URL

2006-10-11 Thread Jeff Pang

From the $ENV{CONTENT_LENGTH}

-Original Message-
From: Anish Kumar K. [EMAIL PROTECTED]
Sent: Oct 11, 2006 2:17 AM
To: beginners@perl.org
Subject: getting the File size of image URL

Is it possible to calculate the File SIZE which is from HTTP. i.e if I 
wanted to know

file size of http://www.yahoo.com/images/a.gif from PERL..

Thanks
Anish


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.2/471 - Release Date: 10/10/2006


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




--
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: Need your help to achieve this?

2006-10-11 Thread Dr.Ruud
Rob Dixon schreef:

 open my $fh, $file or die open '$file': $!;

OP had

  open my $fh, '', $file or die open '$file': $!

which I consider as better.


@data[0..6] = split /,/;

Nice idiom.

-- 
Affijn, Ruud

Gewoon is een tijger.

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




Re: saving surrounding text in substitution

2006-10-11 Thread Dr.Ruud
Kathryn Bushley schreef:

 #!/usr/bin/perl -w
 use warnings;

Make that:

#!/usr/bin/perl
use warnings ;
use strict ;


See `perldoc perllexwarn`.

-- 
Affijn, Ruud

Gewoon is een tijger.

-- 
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 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: need to parse and verify certain content..

2006-10-11 Thread Vishwanath Chitnis

ok, here is the code:

$webserver=apache1;
$platform=solaris;
$uname=abc123;
$password=abc123;

my $ie = Win32::IEAutomation-new(visible=1,maximized=1);

if ($webserver == apache1  $platform == solaris){

$ie-gotoURL('http://xyz.test.com:8900/_cqr/test.cgi');

}

$ie-getTextBox(name:, loginId)-SetValue($uname);# am passing username

$ie-getTextBox(name:, password)-SetValue($password); # to pass the
password

$ie-getButton(caption:, Submit)-Click; #this is to submit the
details...

$ie-getLink(linktext:, xyz)-Click;# after i login i need to click on
particular link on the page
Content();#  after i am navigated,   i am trying to get contents from my
page...not sure if this is correct..
VerifyText($nick=google.com) ;# this is to verify whether google.com is
present in the contents returned...



now i am able to login successfully, and able to navigate to that particular
link as well...but after navigating i have to verify wehther certain
parameters are present or not...this is where i am struck.. any ideas how do
i verify..this
thnx
vish


On 10/11/06, Charles K. Clarkson [EMAIL PROTECTED] wrote:


 Provide a segment of code which can be run and produces
the error you are getting. These three lines of code will
not run. We don't know how you defined the $ie object, for
example. We should be able to copy and paste your supplied
code and run it locally.

Please send your code to the list, not to me personally.
Allow everyone to help you.



Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.
 -Original Message-
*From:* Vishwanath Chitnis [mailto:[EMAIL PROTECTED]
*Sent:* Wednesday, October 11, 2006 2:54 AM
*To:* [EMAIL PROTECTED]
*Subject:* Re: need to parse and verify certain content..



On 10/11/06, Charles K. Clarkson [EMAIL PROTECTED] wrote:

 Vishwanath Chitnis wrote:

 : is there any other way other than above mentioned to do this?

How can we possibly tell with only those lines?

Show more code. Something we can run that will illustrate
 your problem.


 HTH,

 Charles K. Clarkson
 --
 Mobile Homes Specialist
 Free Market Advocate
 Web Programmer



here is sample of code..

$ie-getLink(linktext:, xyz)-Click;#am navigated to my xyz page
Content();#here i am trying to get contents from my page...not sure if
this is correct..
VerifyText($nick=google.com) ;# this is to verify whether google.com is
present in the contents returned...

let me know if you need some more info.

thnx




254 968-8328

 Don't tread on my bandwidth. Trim your posts.


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




modules not found

2006-10-11 Thread Dennis Heuer
Am not shure if this is the right list. I installed perl
into an unusual directory but new modules, like XML-Parser, weren't
able to find installed modules, like ExtUtils. Though the @INC output in
the error message was fully correct. I installed perl into /usr and it
just worked for so. 

Can somebody give me a hint if there's some general problem with perl
when not resided in /usr

Regards,
Dennis Heuer

-- 
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: need to parse and verify certain content..

2006-10-11 Thread Mug
Vishwanath Chitnis wrote:
 ok, here is the code:

 $webserver=apache1;
 $platform=solaris;
 $uname=abc123;
 $password=abc123;

Missed the quotes ??
$webserver = apache1 ;



 my $ie = Win32::IEAutomation-new(visible=1,maximized=1);

 if ($webserver == apache1  $platform == solaris){

if ( $webserver eq apache1  ) {  }

HTH
Mug

-- 
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 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: modules not found

2006-10-11 Thread Jeff Pang

Can somebody give me a hint if there's some general problem with perl
when not resided in /usr


Hello,

Do you know where your modules are installed?Given the path for installed 
modules is /your/path,you can add the path to Perl's @INC by putthing this 
statement at the begin of your scripts:

use lib qw(/your/path);

Then the script or other modules should find the installed modules correctly.





--
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: modules not found

2006-10-11 Thread Dennis Heuer
On Wed, 11 Oct 2006 21:39:22 +0800 (GMT+08:00)
Jeff Pang [EMAIL PROTECTED] wrote:

 
 Can somebody give me a hint if there's some general problem with perl
 when not resided in /usr
 
 
 Hello,
 
 Do you know where your modules are installed?Given the path for installed 
 modules is /your/path,you can add the path to Perl's @INC by putthing this 
 statement at the begin of your scripts:
 
 use lib qw(/your/path);
 
 Then the script or other modules should find the installed modules correctly.
 

As written, the @INC path is set correctly already. Is there some
environment variable I can try?

Dennis

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




Creating RSS feeds with Perl?

2006-10-11 Thread Karjala

How do you create your websites' RSS feeds?

I run a script called createrss.pl as a cron job every hour which checks 
if there are any new stories and if so creates a new feed.rss file


I think this method takes up a lot of RAM and CPU power since it 
launches Perl every hour, but I can't think of anything better.


The other way I thought of (and rejected) was to have the web script 
that accepts a new story from the administrator, to also create the RSS 
file. But I rejected this because if two people might submit a story at 
the same time then the resulting RSS file might only contain one of them.


So, how do you do it?

- Kar


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


Modules for printing the content of an array

2006-10-11 Thread Sami FANTAR

Hello everybody

I would like to know if there is any module which can display in a 
enjoyable way the content of an array with about 200 values.

Could Data::Dumper be a solution for my problem?

Any help or example  will be very appreciated.
Thanks in advance.

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




Re: Modules for printing the content of an array

2006-10-11 Thread Rob Coops

Hi Sami,

Yes Data::Dumper is your friend when it comes to dumping data (how strange
is that :-)

Simply do this in your perl script:
*use Data::Dumper;*
*print Dumper @huge_array;*

And be amazed ;-)





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


Hello everybody

I would like to know if there is any module which can display in a
enjoyable way the content of an array with about 200 values.
Could Data::Dumper be a solution for my problem?

Any help or example  will be very appreciated.
Thanks in advance.

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





Re: Modules for printing the content of an array

2006-10-11 Thread Sami FANTAR

Rob Coops a écrit :

Hi Sami,

Yes Data::Dumper is your friend when it comes to dumping data (how 
strange

is that :-)

Simply do this in your perl script:
*use Data::Dumper;*
*print Dumper @huge_array;*

And be amazed ;-)





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


Hello everybody

I would like to know if there is any module which can display in a
enjoyable way the content of an array with about 200 values.
Could Data::Dumper be a solution for my problem?

Any help or example  will be very appreciated.
Thanks in advance.

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






What do you mean by dumping data?
I have read the Data::Dumper related doc.
But, after having written your example, the output seems quite weird.
I got $VAR1,$VAR2, and so on.
Is it possible to personalize this output?

--
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: Modules for printing the content of an array

2006-10-11 Thread Charles K. Clarkson
Rob Coops wrote:

: Simply do this in your perl script:
: *use Data::Dumper;*
: *print Dumper @huge_array;*

For the archives:

Those asterisks (*) are for emphasis. They are not
actually in the code. Arrays and hashes can also be
dumped using a reference. I find a reference more
aesthetically pleasing.

use Data::Dumper 'Dumper';

print Dumper [EMAIL PROTECTED];


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.


-- 
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, 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: Creating RSS feeds with Perl?

2006-10-11 Thread Tom Phoenix

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


I run a script called createrss.pl as a cron job every hour which checks
if there are any new stories and if so creates a new feed.rss file

I think this method takes up a lot of RAM and CPU power since it
launches Perl every hour, but I can't think of anything better.


A moderately-powerful machine should be capable of tens of thousands
of launches per hour; one more won't be noticeable. Of course, if your
program takes more than 58 minutes to run, maybe there's room for
improvement. :-)


The other way I thought of (and rejected) was to have the web script
that accepts a new story from the administrator, to also create the RSS
file. But I rejected this because if two people might submit a story at
the same time then the resulting RSS file might only contain one of them.


That sounds like a job for flock(). By locking the file, your process
installs a traffic light, so to speak. If everybody uses flock()
properly, each process will wait for a green light before editing the
file.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Help w/map function

2006-10-11 Thread Moon, John
perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,}, map(subt($_),
@a)), \n;
sub subt {my ($a) = @_; $a=~s/^(.*)\..*/$1/; print a=$a\n;
return $a;}'
perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
map(s/^(.*)\..*/$1/, @a)), \n; '
perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
map(s/^(.*)\..*/\1/, @a)), \n; '

Can someone explain why the last two examples don't product the same
output as the first?

Thank you in advance.
jwm

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




Re: Help w/map function

2006-10-11 Thread Jay Savage

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

perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,}, map(subt($_),
@a)), \n;
sub subt {my ($a) = @_; $a=~s/^(.*)\..*/$1/; print a=$a\n;
return $a;}'
perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
map(s/^(.*)\..*/$1/, @a)), \n; '
perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
map(s/^(.*)\..*/\1/, @a)), \n; '

Can someone explain why the last two examples don't product the same
output as the first?

Thank you in advance.
jwm


Sure. It's the first par of the sub:

   my $a = @_;

In scalar context, an array returns the number of elements, so your $a
gets 1. Even though you only pass your sub 1 item, @_ is still an
array. It's a 1-element array, but it's an array. What you want is:

   my $a = shift @_;

Also, for future reference using $a and $b is dangerous and considered
bad form; Perl uses them internally to implement sort.

HTH

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!


Re: Modules for printing the content of an array

2006-10-11 Thread Mumia W.

On 10/11/2006 10:42 AM, Sami FANTAR wrote:

[...]
I have read the Data::Dumper related doc.


Including the part where it tells you how to substitute the correct 
variable names for $VAR1,$VAR2,... ?



But, after having written your example, the output seems quite weird.
I got $VAR1,$VAR2, and so on.
Is it possible to personalize this output?



use Data::Dumper;
my @myarray = qw(blah blahblah blllah);
print Data::Dumper-Dump([EMAIL PROTECTED],[qw(myarray)]);

WARNING: UNTESTED CODE


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




RE: Help w/map function

2006-10-11 Thread Moon, John
On 10/11/06, Moon, John [EMAIL PROTECTED] wrote:
 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,}, map(subt($_),
 @a)), \n;
 sub subt {my ($a) = @_; $a=~s/^(.*)\..*/$1/; print a=$a\n;
 return $a;}'
 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
 map(s/^(.*)\..*/$1/, @a)), \n; '
 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
 map(s/^(.*)\..*/\1/, @a)), \n; '

 Can someone explain why the last two examples don't product the same
 output as the first?

 Thank you in advance.
 jwm

Sure. It's the first par of the sub:

my $a = @_;

In scalar context, an array returns the number of elements, so your $a
gets 1. Even though you only pass your sub 1 item, @_ is still an
array. It's a 1-element array, but it's an array. What you want is:

my $a = shift @_;

Also, for future reference using $a and $b is dangerous and considered
bad form; Perl uses them internally to implement sort.

HTH

Thank you for looking but first part of sub is:
my ($a) = @_;

and the first test script is returning what I want ... it's the second 
third I'm asking about

jwm

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




modules breaking?

2006-10-11 Thread Jesse Engel
i'm getting an error in an installed module, not in my script.

invalid top directory at /System/Library/Perl/5.8.1/File/Find.pm line 568.

script is as follows:

use File::Find;
use Net::FTP;

my $server = blah;
my $login = [EMAIL PROTECTED];
my $pass = blahblah;

my $ftp = Net::FTP-new($server) or die Can't connect: [EMAIL PROTECTED];
$ftp-login($login, $pass) or die couldn't login\n;
my $dir = $ftp-pwd();
my @folders_to_get = $ftp-ls($dir);
sub get_mp3s {
if (-f) {
get($_);
}
}
find(\get_mp3s, @folders_to_get);

(i know, this maybe unrelated) i have had something similar happen when i 
installed coy. i tried
to run the test script and got the following:

Lingua::EN::Inflect::_PL_noun() called too early to check prototype at
/Library/Perl/5.8.1/Lingua/EN/Inflect.pm line 857.
Lingua::EN::Inflect::_PL_noun() called too early to check prototype at
/Library/Perl/5.8.1/Lingua/EN/Inflect.pm line 862.
Modification of a read-only value attempted at 
/Library/Perl/5.8.1/Lingua/EN/Inflect.pm line 140.
Compilation failed in require at /Library/Perl/5.8.1/Coy.pm line 19.
BEGIN failed--compilation aborted at /Library/Perl/5.8.1/Coy.pm line 19.
Compilation failed in require at demo.pl line 3.
BEGIN failed--compilation aborted at demo.pl line 3.

these errors aren't happening in my script, but i'm guessing (at least in the 
case of with
net::ftp) that maybe i'm feeding it the wrong info. whaddya think?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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: Help w/map function

2006-10-11 Thread Paul Johnson
On Wed, Oct 11, 2006 at 07:37:36PM -0400, Moon, John wrote:
 On 10/11/06, Moon, John [EMAIL PROTECTED] wrote:
  perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,}, map(subt($_),
  @a)), \n;
  sub subt {my ($a) = @_; $a=~s/^(.*)\..*/$1/; print a=$a\n;
  return $a;}'
  perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
  map(s/^(.*)\..*/$1/, @a)), \n; '
  perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
  map(s/^(.*)\..*/\1/, @a)), \n; '
 
  Can someone explain why the last two examples don't product the same
  output as the first?
 
  Thank you in advance.
  jwm
 
 Sure. It's the first par of the sub:
 
 my $a = @_;
 
 In scalar context, an array returns the number of elements, so your $a
 gets 1. Even though you only pass your sub 1 item, @_ is still an
 array. It's a 1-element array, but it's an array. What you want is:
 
 my $a = shift @_;
 
 Also, for future reference using $a and $b is dangerous and considered
 bad form; Perl uses them internally to implement sort.
 
 HTH
 
 Thank you for looking but first part of sub is:
 my ($a) = @_;
 
 and the first test script is returning what I want ... it's the second 
 third I'm asking about

Take a look at the return value of s/// in perldoc perlop.

-- 
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: modules breaking?

2006-10-11 Thread Tom Phoenix

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


i'm getting an error in an installed module, not in my script.

invalid top directory at /System/Library/Perl/5.8.1/File/Find.pm line 568.


Yes; but do you see what it's trying to tell you? Some top directory
that you're passing to find() isn't a valid directory name.


my @folders_to_get = $ftp-ls($dir);



find(\get_mp3s, @folders_to_get);


It looks as if your find locations are the directory names on the
remote machine. Do those same names already exist on your machine?
(That would be necessary for find() to use them, of course.)

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: Help w/map function

2006-10-11 Thread Rob Dixon

Moon, John wrote:

 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,}, map(subt($_),
 @a)), \n;
   sub subt {my ($a) = @_; $a=~s/^(.*)\..*/$1/; print a=$a\n;
 return $a;}'
 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
 map(s/^(.*)\..*/$1/, @a)), \n; '
 perl -e '@a=(frc.apmt,frc_ff.apmt);print join(q{,},
 map(s/^(.*)\..*/\1/, @a)), \n; '

 Can someone explain why the last two examples don't product the same
 output as the first?

Hi John

Here's your code again, laid out a little more visibly:


use strict;
use warnings;

my @a;

@a = qw/frc.apmt frc_ff.apmt/;
print join(q{,}, map(subt($_), @a)), \n\n;

@a = qw/frc.apmt frc_ff.apmt/;
print join(q{,}, map(s/^(.*)\..*/$1/, @a)), \n\n;

@a = qw/frc.apmt frc_ff.apmt/;
print join(q{,}, map(s/^(.*)\..*/\1/, @a)), \n\n;

sub subt {
  my ($a) = @_;
  $a =~ s/^(.*)\..*/$1/;
  print a=$a\n;
  return $a;
}


and the output is:

\1 better written as $1 at E:\Perl\source\x.pl line 13.
a=frc
a=frc_ff
frc,frc_ff

1,1

1,1


In the latter two cases your call to map generates a list consisting of the
return values of the subtitution operator acting on each list element. Those
values are the number of substitutions made on the string, so all the values in
your array are altered in place and your result is a list of 1s as one
substitution was done on each element.

(You will see that adding 'use warnings' caused Perl to chastise you for using
\1 in the last case instead of the correct $1.)

To write this correctly, use something like


@a = qw/frc.apmt frc_ff.apmt/;
print join(q{,}, map /([^.]*)/, @a), \n\n;


will do the trick. The return value of the match operator in list context is the
value of the captured subexpressions, which in this case is all the non-dot
characters from the beginning of the string. Note that this alternative doesn't
modify the original array at all.


HTH,

Rob


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