Re: Command line vs. cron

2006-09-12 Thread James Marks


On Sep 12, 2006, at 11:02 PM, Mumia W. wrote:


On 09/12/2006 11:28 PM, James Marks wrote:

Hi folks,
I don't know if this is a Perl or UNIX problem and I'm hoping you can 
help me figure that out.
I wrote a script that checks to see if the httpsd and mysqld 
processes are running on my server and to log the results of those 
tests.
When I run the script from the command line, the script prints to a 
log file the number of each of those processes that are running at 
the time of the script execution. When I run the same script from 
cron, however, it only prints a "1" for httpsd and mysqld.

[...]
my $httpsd_count = `ps -aux | grep -c httpsd`;
my $mysqld_count = `ps -aux | grep -c mysqld`;
[...]
Any ideas on why the same script has different results when run from 
the command line vs. from cron?

Thanks,
James


I don't know if this would affect the output, but "ps -aux" gives me 
this in addition to the normal output: "Warning: bad syntax, perhaps a 
bogus '-'? See http://procps.sf.net/faq.html";


Perhaps "ps hcax" would suffice.

Also, watch what the "grep -c ..." is doing. Perhaps the counting 
isn't going as planned. I would count from within Perl.


This is how I might write the script:

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

local $\ = "\n";
local $, = " ";
my $ps = `ps hcax`;
my $logfile = '/tmp/counts-ma.log';
my $tty = `tty`;
chomp $tty;
my $mysqlc = () = $ps =~ m/\bmysqld\b/g;
my $httpdc = () = $ps =~ m/\bapache2\b/g;

open (STDOUT, '>>', $logfile) or die("Couldn't write to
$logfile\n");
my $date = `date +"%Y-%m-%d %H:%M:%S"`;
chomp $date;
print $date, httpd => $httpdc, mysql => $mysqlc;


Thanks, Mumia. That seems to work both from the command line and from 
cron. (I'm not sure what purpose $tty serves. I took it out and it runs 
fine without it.)


I'm still baffled as to why the original script runs differently when 
run by cron rather than from the command line. Can anybody explain 
that?


James


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Command line vs. cron

2006-09-12 Thread Mumia W.

On 09/12/2006 11:28 PM, James Marks wrote:

Hi folks,

I don't know if this is a Perl or UNIX problem and I'm hoping you can 
help me figure that out.


I wrote a script that checks to see if the httpsd and mysqld processes 
are running on my server and to log the results of those tests.


When I run the script from the command line, the script prints to a log 
file the number of each of those processes that are running at the time 
of the script execution. When I run the same script from cron, however, 
it only prints a "1" for httpsd and mysqld.


[...]
my $httpsd_count = `ps -aux | grep -c httpsd`;
my $mysqld_count = `ps -aux | grep -c mysqld`;
[...]

Any ideas on why the same script has different results when run from the 
command line vs. from cron?


Thanks,

James




I don't know if this would affect the output, but "ps -aux" 
gives me this in addition to the normal output: "Warning: bad 
syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html";


Perhaps "ps hcax" would suffice.

Also, watch what the "grep -c ..." is doing. Perhaps the 
counting isn't going as planned. I would count from within Perl.


This is how I might write the script:

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

local $\ = "\n";
local $, = " ";
my $ps = `ps hcax`;
my $logfile = '/tmp/counts-ma.log';
my $tty = `tty`;
chomp $tty;
my $mysqlc = () = $ps =~ m/\bmysqld\b/g;
my $httpdc = () = $ps =~ m/\bapache2\b/g;

open (STDOUT, '>>', $logfile) or die("Couldn't write to
$logfile\n");
my $date = `date +"%Y-%m-%d %H:%M:%S"`;
chomp $date;
print $date, httpd => $httpdc, mysql => $mysqlc;




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Command line vs. cron

2006-09-12 Thread James Marks


On Sep 12, 2006, at 10:28 PM, Owen Cook wrote:


Here's the script:

#!/usr/bin/perl

use warnings;
use strict;

my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file';

open FILE_OUT, ">> $log_file"
 or die "Cannot open log file: $!";

select FILE_OUT;

(my $month, my $day, my $year, my $hour, my $minute, my $second) =
(localtime)[4, 3, 5, 2, 1, 0];

printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day,
$hour, $minute, $second);

my $httpsd_count = `ps -aux | grep -c httpsd`;
my $mysqld_count = `ps -aux | grep -c mysqld`;

chomp($httpsd_count);
chomp($mysqld_count);

my $httpsd_msg = '';
my $mysqld_msg = '';

if ($httpsd_count > 0) {
 print "httpsd $httpsd_count ";
}
else {
 print "httpsd NOT RUNNING ";
}

if ($mysqld_count > 0) {
 print "mysqld $mysqld_count ";
}
else {
 print "mysqld NOT RUNNING ";
}

print "\n";

close FILE_OUT;




I suspect that your env includes the path to "ps"

For cron you would need the full path

Try
 my $httpsd_count = `/usr/bin/ps -aux | grep -c httpsd`;
 my $mysqld_count = `/usr/bin/ps -aux | grep -c mysqld`;


I just tried that and let it run in cron but there's no difference in
output. I still get "1"s in cron and process counts from the command
line.


Ooops, how about the full path to grep as well!

 my $httpsd_count = `/usr/bin/ps -aux | /usr/bin/grep -c httpsd`;
 my $mysqld_count = `/usr/bin/ps -aux | /usr/bin/grep -c mysqld`;


Tried adding the full path to grep and it just gets worse:

my $httpsd_count = `/bin/ps -aux | /usr/bin/grep -c httpsd`;
my $mysqld_count = `/bin/ps -aux | /usr/bin/grep -c mysqld`;

(on my machine, ps is in /bin)

cron:
2006-08-12 22:30:20 httpsd NOT RUNNING mysqld NOT RUNNING
2006-08-12 22:32:20 httpsd NOT RUNNING mysqld NOT RUNNING
2006-08-12 22:34:20 httpsd NOT RUNNING mysqld NOT RUNNING

command line:
2006-08-12 22:34:41 httpsd 20 mysqld 31



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Command line vs. cron

2006-09-12 Thread Owen Cook

On Tue, 12 Sep 2006, James Marks wrote:

> 
> On Sep 12, 2006, at 9:59 PM, Owen Cook wrote:
> 
> >> Here's the script:
> >>
> >> #!/usr/bin/perl
> >>
> >> use warnings;
> >> use strict;
> >>
> >> my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file';
> >>
> >> open FILE_OUT, ">> $log_file"
> >>  or die "Cannot open log file: $!";
> >>
> >> select FILE_OUT;
> >>
> >> (my $month, my $day, my $year, my $hour, my $minute, my $second) =
> >> (localtime)[4, 3, 5, 2, 1, 0];
> >>
> >> printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day,
> >> $hour, $minute, $second);
> >>
> >> my $httpsd_count = `ps -aux | grep -c httpsd`;
> >> my $mysqld_count = `ps -aux | grep -c mysqld`;
> >>
> >> chomp($httpsd_count);
> >> chomp($mysqld_count);
> >>
> >> my $httpsd_msg = '';
> >> my $mysqld_msg = '';
> >>
> >> if ($httpsd_count > 0) {
> >>  print "httpsd $httpsd_count ";
> >> }
> >> else {
> >>  print "httpsd NOT RUNNING ";
> >> }
> >>
> >> if ($mysqld_count > 0) {
> >>  print "mysqld $mysqld_count ";
> >> }
> >> else {
> >>  print "mysqld NOT RUNNING ";
> >> }
> >>
> >> print "\n";
> >>
> >> close FILE_OUT;
> >>
> >
> >
> > I suspect that your env includes the path to "ps"
> >
> > For cron you would need the full path
> >
> > Try
> >  my $httpsd_count = `/usr/bin/ps -aux | grep -c httpsd`;
> >  my $mysqld_count = `/usr/bin/ps -aux | grep -c mysqld`;
> 
> I just tried that and let it run in cron but there's no difference in 
> output. I still get "1"s in cron and process counts from the command 
> line.

Ooops, how about the full path to grep as well!

 my $httpsd_count = `/usr/bin/ps -aux | /usr/bin/grep -c httpsd`;
 my $mysqld_count = `/usr/bin/ps -aux | /usr/bin/grep -c mysqld`;


Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Command line vs. cron

2006-09-12 Thread James Marks


On Sep 12, 2006, at 9:59 PM, Owen Cook wrote:


Here's the script:

#!/usr/bin/perl

use warnings;
use strict;

my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file';

open FILE_OUT, ">> $log_file"
 or die "Cannot open log file: $!";

select FILE_OUT;

(my $month, my $day, my $year, my $hour, my $minute, my $second) =
(localtime)[4, 3, 5, 2, 1, 0];

printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day,
$hour, $minute, $second);

my $httpsd_count = `ps -aux | grep -c httpsd`;
my $mysqld_count = `ps -aux | grep -c mysqld`;

chomp($httpsd_count);
chomp($mysqld_count);

my $httpsd_msg = '';
my $mysqld_msg = '';

if ($httpsd_count > 0) {
 print "httpsd $httpsd_count ";
}
else {
 print "httpsd NOT RUNNING ";
}

if ($mysqld_count > 0) {
 print "mysqld $mysqld_count ";
}
else {
 print "mysqld NOT RUNNING ";
}

print "\n";

close FILE_OUT;




I suspect that your env includes the path to "ps"

For cron you would need the full path

Try
 my $httpsd_count = `/usr/bin/ps -aux | grep -c httpsd`;
 my $mysqld_count = `/usr/bin/ps -aux | grep -c mysqld`;


I just tried that and let it run in cron but there's no difference in 
output. I still get "1"s in cron and process counts from the command 
line.


cron:
2006-08-12 22:15:20 httpsd 1 mysqld 1

command line:
2006-08-12 22:19:18 httpsd 19 mysqld 30


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Command line vs. cron

2006-09-12 Thread Owen Cook

On Tue, 12 Sep 2006, James Marks wrote:

> Hi folks,
> 
> I don't know if this is a Perl or UNIX problem and I'm hoping you can 
> help me figure that out.
> 
> I wrote a script that checks to see if the httpsd and mysqld processes 
> are running on my server and to log the results of those tests.
> 
> When I run the script from the command line, the script prints to a log 
> file the number of each of those processes that are running at the time 
> of the script execution. When I run the same script from cron, however, 
> it only prints a "1" for httpsd and mysqld.


> 
> 
> 
> Here's the cron entry:
> 
> */15*   *   *   *   perl 
> /home/james/code/cron_code/httpsd_mysqld_check.pl
> 
> 
> 
> Here's the script:
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file';
> 
> open FILE_OUT, ">> $log_file"
>  or die "Cannot open log file: $!";
> 
> select FILE_OUT;
> 
> (my $month, my $day, my $year, my $hour, my $minute, my $second) = 
> (localtime)[4, 3, 5, 2, 1, 0];
> 
> printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day, 
> $hour, $minute, $second);
> 
> my $httpsd_count = `ps -aux | grep -c httpsd`;
> my $mysqld_count = `ps -aux | grep -c mysqld`;
> 
> chomp($httpsd_count);
> chomp($mysqld_count);
> 
> my $httpsd_msg = '';
> my $mysqld_msg = '';
> 
> if ($httpsd_count > 0) {
>  print "httpsd $httpsd_count ";
> }
> else {
>  print "httpsd NOT RUNNING ";
> }
> 
> if ($mysqld_count > 0) {
>  print "mysqld $mysqld_count ";
> }
> else {
>  print "mysqld NOT RUNNING ";
> }
> 
> print "\n";
> 
> close FILE_OUT;
> 


I suspect that your env includes the path to "ps"

For cron you would need the full path

Try 
 my $httpsd_count = `/usr/bin/ps -aux | grep -c httpsd`;
 my $mysqld_count = `/usr/bin/ps -aux | grep -c mysqld`;

or wherever ps is



Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Command line vs. cron

2006-09-12 Thread James Marks

Hi folks,

I don't know if this is a Perl or UNIX problem and I'm hoping you can 
help me figure that out.


I wrote a script that checks to see if the httpsd and mysqld processes 
are running on my server and to log the results of those tests.


When I run the script from the command line, the script prints to a log 
file the number of each of those processes that are running at the time 
of the script execution. When I run the same script from cron, however, 
it only prints a "1" for httpsd and mysqld.




script output to log when run from the command line:

2006-08-12 21:10:20 httpsd 23 mysqld 33



script output to log when run from cron:

2006-08-12 21:11:05 httpsd 1 mysqld 1



Here's the cron entry:

*/15*   *   *   *   perl 
/home/james/code/cron_code/httpsd_mysqld_check.pl




Here's the script:

#!/usr/bin/perl

use warnings;
use strict;

my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file';

open FILE_OUT, ">> $log_file"
or die "Cannot open log file: $!";

select FILE_OUT;

(my $month, my $day, my $year, my $hour, my $minute, my $second) = 
(localtime)[4, 3, 5, 2, 1, 0];


printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day, 
$hour, $minute, $second);


my $httpsd_count = `ps -aux | grep -c httpsd`;
my $mysqld_count = `ps -aux | grep -c mysqld`;

chomp($httpsd_count);
chomp($mysqld_count);

my $httpsd_msg = '';
my $mysqld_msg = '';

if ($httpsd_count > 0) {
print "httpsd $httpsd_count ";
}
else {
print "httpsd NOT RUNNING ";
}

if ($mysqld_count > 0) {
print "mysqld $mysqld_count ";
}
else {
print "mysqld NOT RUNNING ";
}

print "\n";

close FILE_OUT;



Any ideas on why the same script has different results when run from 
the command line vs. from cron?


Thanks,

James


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Print output of Table on browser as it is being created

2006-09-12 Thread jeffhua
 
Hi,
You just need to print the table lines in a loop when you're querying the datas 
from db.
for example,maybe you can write it like:
 
print "";
while(my $sql_line_ref = $sth->fetchrow_hashref) {
   print qq {$sql_line_ref->{key1}
  $sql_line_ref->{key2}

  };
}
print "";
 
 
Hope this helps and no test.
 
-jeff
 
 
 
Subject: Print output of Table on browser as it is being created


I am trying to find out how can i modify my CGI script so that I can 
it can print out the long table of data as it is running the query. 
 
is there any example that I can follow on? 
 
 

Check out the new AOL.  Most comprehensive set of free safety and security 
tools, free access to millions of high-quality videos from across the web, free 
AOL Mail and more.


Re: Parse Help

2006-09-12 Thread Dr.Ruud
Dr.Ruud schreef:
> John W. Krahn:

>> my @p_var = map {
>> ( my $x = $_ ) =~ s/=?> } $text =~ /(p_var\d+=?<[^>]*)>/g;
>>
>> print for @p_var;
>
>  my %p = /(p_var\d+)=?<([^>]*)>/g;
>  for my $k(sort keys %p) {print "$k='$p{$k}'"}

More variants:

   my %p = /(p_var\d+)=?<([^>]*)>/g;
   print "$_='$p{$_}'" for sort keys %p;

   my @p = /(p_var\d+)=?<([^>]*)>/g;
   print "$p[2*$_]='$p[2*$_+1]'" for 0..$#p/2;


   my @p; push @p,"$1='$2'" while/(p_var\d+)=?<([^>]*)>/g;
   print for @p;

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Parse Help

2006-09-12 Thread Dr.Ruud
"John W. Krahn" schreef:

> my @p_var = map {
> ( my $x = $_ ) =~ s/=? } $text =~ /(p_var\d+=?<[^>]*)>/g;
>
> print for @p_var;

  my %p = /(p_var\d+)=?<([^>]*)>/g;
  for my $k(sort keys %p)
{print "$k='$p{$k}'"}

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to search POD

2006-09-12 Thread Ken Foskey
On Mon, 2006-09-11 at 06:37 -0700, chen li wrote:

> Another question: sometimes some PODs are very long I
> can't go back  once I read to the end. The only way I
> can go back is to issue the line code again. Is there
> any way around this problem under window prompt?

The other trick I use is pod2wiki for my internal modules and use twiki
for my documentation.  I then use the twiki search function to search my
pod text.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: cpan and make test

2006-09-12 Thread Tom Phoenix

On 9/12/06, Umar Draz <[EMAIL PROTECTED]> wrote:


  some time i got erorr on make test when i use cpan -i 
is it possible to bypass ?


Sure, if you don't care whether your modules work properly or not. In
the long run, though, it's probably worth fixing the bugs. Cheers!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Print output of Table on browser as it is being created

2006-09-12 Thread ubergoonz

I am trying to find out how can i modify my CGI script so that I can
it can print out the long table of data as it is running the query.

is there any example that I can follow on?



--
Best Regards,
another perl newbie
ubergoonz

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: parse order number from yppoll command

2006-09-12 Thread ubergoonz

Ahh Thanks John !!

it works now.



On 9/12/06, John W. Krahn <[EMAIL PROTECTED]> wrote:

ubergoonz wrote:
> I am trying to creat a CGI page that display the ordernumber of the
> yppoll output on all my NIS servers, using the following
> my $svr_order = `yppoll $nissvr $map | grep order| awk '{print $NF}'`;
>
> but it just seems to be empty.
>
> any idea how can I fix this?

It is probably an interpolation problem as that string is interpolated by both
perl and the shell.  Try it like this:


open my $pipe, '-|', 'yppoll', $nissvr, $map
or die "Cannot open pipe from 'yppoll' $!";

while ( <$pipe> ) {
print +( split )[ -1 ] if /order/;
}

close $pipe or warn $! ? "Error closing 'yppoll' pipe: $!"
   : "Exit status $? from 'yppoll'";



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






--
Best Regards,
Leslie Joshua Wang
++
"I believe there's a hero in everyone of us, give us strength, make us
noble, even though sometimes, we have to give up the things we want
the most."
++
"The good thing about standard,  there are so many of them to chose from ..."

availability, performance and cost - pick 2

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: temporarily change a function, sort of like doing a local $var;

2006-09-12 Thread JupiterHost.Net



What the statement does

local *What::ever = \&my_sub; # with a named sub
or
local *What::ever = sub { }; # with a closure

is to locally redefine the *What::ever{CODE} slot of the glob.



Adriano, *you* are awesome! I've been fiddling with this sort of thing 
dancing around the right way and BAM you come though!


Thanks a bunch!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




cpan and make test

2006-09-12 Thread Umar Draz
hi dear members!

  some time i got erorr on make test when i use cpan -i  is it 
possible to bypass ?

Regards,

Umar Draz


-
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
countries) for 2ยข/min or less.

Re: temporarily change a function, sort of like doing a local $var;

2006-09-12 Thread Adriano Ferreira

On 9/12/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:

I'm trying to change the behavior of a function (whose use of and call I
have no control over) to avoid some nasty behavior in certain circumstances.



Its easy enough to redefine it but after the hairy part is done I want
to change it back.

Similar to how you can:
 local $var;


What you need is just a "local *What::ever = \&new_sub;" I tried to
write similar to what you need. The code below overrides
File::Copy::copy so that it dumps the arguments before copying. This
is done inside a block:

  #!/usr/bin/perl

  use strict;
  use warnings;

  use File::Copy ();

  my ($source, $target) = @ARGV;

  {
  my $copy = \&File::Copy::copy; # save it
  #no warnings qw(redefine);
  local *File::Copy::copy = sub {
  warn "copy(@_)\n";
  $copy->(@_);
  };

  File::Copy::copy($source, $target);


  }

  # File::Copy::copy is magically restored here

If you don't use the "no warnings" bit you will see a "Subroutine
File::Copy::copy redefined".

You don't need to save it like I did at "my $copy =
\&File::Copy::copy; # save it" if you don't need the old code. In the
example, I just added behavior and invoked the old code to do the hard
work.

What the statement does

local *What::ever = \&my_sub; # with a named sub
or
local *What::ever = sub { }; # with a closure

is to locally redefine the *What::ever{CODE} slot of the glob.

Regards,
Adriano.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Need help Win#2 Directory Walk and testing for file access

2006-09-12 Thread John W. Krahn
Gallagher, Tim F (NE) wrote:
> I need to move 3TB of data to a new SAN.  I have to make sure that I
> have the correct tights to move the data so I want to test my data
> before the move.  I want to walk the data and see if I have access to
> all the files.  I am not sure how to test the files to see if I have
> access or not.  I don't need to know what access I need to know if
> anyone took my group out.  I can still stat a file but how can I test
> for write access without writing to a file.

perldoc -f -w
perldoc -f -W



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




temporarily change a function, sort of like doing a local $var;

2006-09-12 Thread JupiterHost.Net

Howdy,


I'm trying to change the behavior of a function (whose use of and call I 
have no control over) to avoid some nasty behavior in certain circumstances.


Its easy enough to redefine it but after the hairy part is done I want 
to change it back.


Similar to how you can:

 {
local $var;
...
 }

# $var back to what it was before that block

except I need to do it with a function:


sub What::ever { return }

do_scary_stuff_that_what_ever_usually_breaks();

restore_back_to_original_state_the_function('What::ever');

Like I said changing it in the first place is easy and can be done 
several ways but is there a way to do it and  get it back to how it was?


(Yes I fiddled with ref's, changing it changes what its referenced to so 
the ref now points to the new version like you'd expect...)


TIA!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Parse Help

2006-09-12 Thread John W. Krahn
John W. Krahn wrote:
> 
> $ perl -le'
> my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2=
> KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
> 52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3: 48,48,49//p_var5=<12345>
> KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907> KQt=1 HZZ=8:
> 50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
> 48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<> 
> NULL!;
> 
> my @p_var = $text =~ /<([^>]*)>/g;
> 
> print ">$_<" for @p_var;
> '
>>SD<
>>QR44<
>>543210987<
>>001<
>>12345<
>>20060907<
>>000WR44<
>>X<
>><

Oops!

my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2=
KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3: 48,48,49//p_var5=<12345>
KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907> KQt=1 HZZ=8:
50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<> NULL!;

my @p_var = map {
( my $x = $_ ) =~ s/=?]*)>/g;

print for @p_var;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Need help Win#2 Directory Walk and testing for file access

2006-09-12 Thread D. Bolliger
Gallagher, Tim F (NE) am Dienstag, 12. September 2006 20:39:
> I need to move 3TB of data to a new SAN.  I have to make sure that I
> have the correct tights to move the data so I want to test my data
> before the move.  I want to walk the data and see if I have access to
> all the files.  I am not sure how to test the files to see if I have
> access or not.  I don't need to know what access I need to know if
> anyone took my group out.  I can still stat a file but how can I test
> for write access without writing to a file.  Here is what I have
>
> use File::DirWalk;
> my $dw = new File::DirWalk;
> $dw->onFile(sub {
> my ($file) = @_;
> if(length($file) < 1)

I don't work on windows anymore, but what about 

  if (-r $file) # is file readable?

See perldoc -f -X

(I don't quite understand why you should have to test for *write* access of 
files to copy ?!? If you have to: Try the -w test)

>
> {
> print " #!!!### --> Paused File =
> $file\n";
> $pause = ;
> }
> print $file . "\n";
> return File::DirWalk::SUCCESS;
> });
>
> my($walkPath) = @ARGV;
> chomp($walkPath);
> $dw->walk($walkPath);
>
> I used a length comparison to see if files that I don't have access too
> returns a length.  Any Ideas?

Hope this helps

Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Need help Win#2 Directory Walk and testing for file access

2006-09-12 Thread Gallagher, Tim F \(NE\)
I need to move 3TB of data to a new SAN.  I have to make sure that I
have the correct tights to move the data so I want to test my data
before the move.  I want to walk the data and see if I have access to
all the files.  I am not sure how to test the files to see if I have
access or not.  I don't need to know what access I need to know if
anyone took my group out.  I can still stat a file but how can I test
for write access without writing to a file.  Here is what I have

 

use File::DirWalk;

my $dw = new File::DirWalk;

$dw->onFile(sub {

my ($file) = @_;

if(length($file) < 1)

{

print " #!!!### --> Paused File =
$file\n";

$pause = ;

}



print $file . "\n";

return File::DirWalk::SUCCESS;

});

 

my($walkPath) = @ARGV;

chomp($walkPath);

$dw->walk($walkPath);

 

I used a length comparison to see if files that I don't have access too
returns a length.  Any Ideas?

 

Thanks

 

-T

 

 



Re: Downloading a file through a filehandle

2006-09-12 Thread Mumia W.

On 09/11/2006 05:58 PM, Robin Sheat wrote:

On Tuesday 12 September 2006 10:27, Rob Dixon wrote:

[...]
What may help is that LWP allows for a callback to be specified in the 
get() call, so that the downloaded data can be passed in chunks to a 
user-written subroutine as it arrives. Use

   $agent->get($url, ':content_cb' => \&callback);
Hmm, that looks promising. But it would require making a significant bit of my 
code a lot less generic.

[...]


I'm also out of my depth here, but you might be able to 
subclass IO::Handle to create a class that makes a LWP 
connection look like a file handle.





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Parse Help

2006-09-12 Thread Jeff Westman

Too easy!  THANKS JOHN!!!




On 9/12/06, John W. Krahn <[EMAIL PROTECTED]> wrote:


Jeff Westman wrote:
> Hello,

Hello,

> I have a string that I would like to parse and change the format.  I'm
not
> that good at 'map' and I'm just looking for a quick-and-dirty way of
doing
> this.  I've tried substr and split, but there has to be a simple way to
do
> this.
>
> My text string looks like
>
> [20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2= KQt=1
> HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
> 52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3:
> 48,48,49//p_var5=<12345> KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907>
> KQt=1 HZZ=8: 50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
> 48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2:
83,68//p_var9=<>
> NULL
>
> (one lone line)
>
> I would like it "cleaned up" to look like
>
> p_var1='SD'
> p_var2='QR44'
> p_var3='543210987'
> p_var4='001'
> p_var5='12345'
> p_var6='20060907'
> p_var7='000WR44'
> p_var8='X'
> p_var9=''
>
> This is not 'production' or a school assignment, just the output from a
> file
> I need to make easier to read.
>
> Any help would be appreciated!!!

$ perl -le'
my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2:
83,68//p_var2=
KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3:
48,48,49//p_var5=<12345>
KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907> KQt=1 HZZ=8:
50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<>
NULL!;

my @p_var = $text =~ /<([^>]*)>/g;

print ">$_<" for @p_var;
'
>SD<
>QR44<
>543210987<
>001<
>12345<
>20060907<
>000WR44<
>X<
><




John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 





RE: Parse Help

2006-09-12 Thread Charles K. Clarkson
Jeff Westman wrote:

: I would like it "cleaned up" to look like
: 
: p_var1='SD'
: p_var2='QR44'
: p_var3='543210987'
: p_var4='001'
: p_var5='12345'
: p_var6='20060907'
: p_var7='000WR44'
: p_var8='X'
: p_var9=''

#!/usr/bin/perl

use strict;
use warnings;

my $input = q{ [20060911 14:47:11]p_var1= KQt=1 HZZ=2:
83,68//p_var2= KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1
HZZ=9:52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1
HZZ=3:48,48,49//p_var5=<12345> KQt=1 HZZ=5:
49,50,51,52,53//p_var6=<20060907> KQt=1 HZZ=8:
50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1
HZZ=11:48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2:
83,68//p_var9=<>NULL };

my @report;
foreach ( $input =~ /(p_var[^>]+>)/g ) {

# change <> to single quote
tr/<>/'/;

# add = if missing
s/'/='/ unless /\d=/;

# add to report
push @report, $_;
}

# print report
print "$_\n" foreach @report;

__END__


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]
 




Re: Parse Help

2006-09-12 Thread John W. Krahn
Jeff Westman wrote:
> Hello,

Hello,

> I have a string that I would like to parse and change the format.  I'm not
> that good at 'map' and I'm just looking for a quick-and-dirty way of doing
> this.  I've tried substr and split, but there has to be a simple way to do
> this.
> 
> My text string looks like
> 
> [20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2= KQt=1
> HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
> 52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3:
> 48,48,49//p_var5=<12345> KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907>
> KQt=1 HZZ=8: 50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
> 48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<>
> NULL
> 
> (one lone line)
> 
> I would like it "cleaned up" to look like
> 
> p_var1='SD'
> p_var2='QR44'
> p_var3='543210987'
> p_var4='001'
> p_var5='12345'
> p_var6='20060907'
> p_var7='000WR44'
> p_var8='X'
> p_var9=''
> 
> This is not 'production' or a school assignment, just the output from a
> file
> I need to make easier to read.
> 
> Any help would be appreciated!!!

$ perl -le'
my $text = q![20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2=
KQt=1 HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3: 48,48,49//p_var5=<12345>
KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907> KQt=1 HZZ=8:
50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<> NULL!;

my @p_var = $text =~ /<([^>]*)>/g;

print ">$_<" for @p_var;
'
>SD<
>QR44<
>543210987<
>001<
>12345<
>20060907<
>000WR44<
>X<
><




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Parse Help

2006-09-12 Thread Jeff Westman

Hello,

I have a string that I would like to parse and change the format.  I'm not
that good at 'map' and I'm just looking for a quick-and-dirty way of doing
this.  I've tried substr and split, but there has to be a simple way to do
this.

My text string looks like

[20060911 14:47:11]p_var1= KQt=1 HZZ=2: 83,68//p_var2= KQt=1
HZZ=4: 77,57,52,52//p_var3=<543210987> KQt=1 HZZ=9:
52,54,48,52,50,57,49,56,50//p_var4=<001> KQt=1 HZZ=3:
48,48,49//p_var5=<12345> KQt=1 HZZ=5: 49,50,51,52,53//p_var6=<20060907>
KQt=1 HZZ=8: 50,48,48,54,48,57,48,55//p_var7=<000WR44> KQt=1 HZZ=11:
48,48,48,48,48,48,48,77,57,52,52//p_var8 KQt=1 HZZ=2: 83,68//p_var9=<>
NULL

(one lone line)

I would like it "cleaned up" to look like

p_var1='SD'
p_var2='QR44'
p_var3='543210987'
p_var4='001'
p_var5='12345'
p_var6='20060907'
p_var7='000WR44'
p_var8='X'
p_var9=''

This is not 'production' or a school assignment, just the output from a file
I need to make easier to read.

Any help would be appreciated!!!

TIA

Jeff


Re: Archive Zip

2006-09-12 Thread Derek B. Smith
--- Rob Dixon <[EMAIL PROTECTED]> wrote:

> Derek B. Smith wrote:
> >
> > --- Tom Phoenix <[EMAIL PROTECTED]> wrote:
> >
> >>On 9/11/06, Derek B. Smith
> >><[EMAIL PROTECTED]> wrote:
> >>
> >>>I need to compress a bunch of files, so instead
> of making a system call to
> >>>gzip I figured to try out Archive::Zip. After
> running this code it creates a
> >>>new file but is larger in size.
> >>
> >>That module automatically uses Compress::Zlib to
> compress the data. Were any
> >>of the files compressed before you started?
> Compression algorithms can't
> >>shrink every file, and files that have compact
> formats can't be shrunk. If you
> >>try collecting the files with another archiving
> tool, you should see roughly
> >>the same results, if they're already compact: The
> archive will be roughly the
> >>same size as the uncompressed data, or a little
> larger.
> >>
> >>Cheers!
> >>
> >>--Tom Phoenix
> >
> >
> > **
> > Thank you 4 replying!.
> > The files attributes prior to using gzip were:
> > -rw-r--r--   1 root   sys9007879 Sep
> 11
> > 15:24 derek.log
> >
> > after compression using gzip are:
> > -rw-r--r--   1 root   sys 393013 Sep
> 11
> > 15:24 derek.log.gz
> >
> > as you can see this file was compressed
> significantly
> > as it is a large text based file:
> > #>file derek.log
> > derek.log:  ascii text
> >
> > Is this code syntactically correct to produce a
> zipped
> > file ?  I read the POD and there are no clear
> > examples. Please help...thank you
> > derek
> >
> >
> > #!/usr/bin/perl
> >
> > use strict;
> > use warnings;
> > use diagnostics;
> > use Data::Dumper;
> > use Readonly;
> > use Archive::Zip qw ( :ERROR_CODES :CONSTANTS );
> >
> > my $zip = Archive::Zip->new();
> >
> > # add all readable files and directories
> >   $zip->addTree( '/usr/local/admin', 'derek' );
> >   # and write them into a file
> >   $zip->writeToFileNamed('xxx.zip');
> 
> That looks fine to me Derek, but of course it
> depends on what you're trying to
> do! What you have written will add (as your comment
> says) all readable files and
> directories at or below /usr/local/admin. Check the
> resulting zip file to see if
> it has stuff in it you didn't mean to archive.
> 
> I wonder if you just meant to zip derek.log? If so,
> then replace the addTree
> method call with
> 
>   my $entry =
> $zip->addFile('/usr/local/admin/derek.log',
> 'derek.log') or die 'Failed to add file';
> 
> and if you want the target file as small as possible
> (at the expense of a longer
> compression time) then add:
> 
>   $entry->desiredCompressionLevel(9);
> 
> after the call to addFile and before
> writeToFileNamed.
> 
> HTH,
> 
> Rob
> 
**
Rob, 

Initially I was playing with addFile but opted for the
addTree...anyway your ideas did the trick...thank you!
> 
> 
> 


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




Re: How to search POD

2006-09-12 Thread Ken Foskey
On Mon, 2006-09-11 at 06:37 -0700, chen li wrote:
> Dear all,
> 
> There are several methods to search POD on window

I found podbrowser it is excellent for finding and reviewing pod
documents that are installed.

http://jodrell.net/projects/podbrowser

Thanks
Ken Foskey


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Archive Zip

2006-09-12 Thread Rob Dixon

Derek B. Smith wrote:


--- Tom Phoenix <[EMAIL PROTECTED]> wrote:


On 9/11/06, Derek B. Smith
<[EMAIL PROTECTED]> wrote:


I need to compress a bunch of files, so instead of making a system call to
gzip I figured to try out Archive::Zip. After running this code it creates a
new file but is larger in size.


That module automatically uses Compress::Zlib to compress the data. Were any
of the files compressed before you started? Compression algorithms can't
shrink every file, and files that have compact formats can't be shrunk. If you
try collecting the files with another archiving tool, you should see roughly
the same results, if they're already compact: The archive will be roughly the
same size as the uncompressed data, or a little larger.

Cheers!

--Tom Phoenix



**
Thank you 4 replying!.
The files attributes prior to using gzip were:
-rw-r--r--   1 root   sys9007879 Sep 11
15:24 derek.log

after compression using gzip are:
-rw-r--r--   1 root   sys 393013 Sep 11
15:24 derek.log.gz

as you can see this file was compressed significantly
as it is a large text based file:
#>file derek.log
derek.log:  ascii text

Is this code syntactically correct to produce a zipped
file ?  I read the POD and there are no clear
examples. Please help...thank you
derek


#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use Readonly;
use Archive::Zip qw ( :ERROR_CODES :CONSTANTS );

my $zip = Archive::Zip->new();

# add all readable files and directories
  $zip->addTree( '/usr/local/admin', 'derek' );
  # and write them into a file
  $zip->writeToFileNamed('xxx.zip');


That looks fine to me Derek, but of course it depends on what you're trying to
do! What you have written will add (as your comment says) all readable files and
directories at or below /usr/local/admin. Check the resulting zip file to see if
it has stuff in it you didn't mean to archive.

I wonder if you just meant to zip derek.log? If so, then replace the addTree
method call with

 my $entry = $zip->addFile('/usr/local/admin/derek.log', 'derek.log') or die 
'Failed to add file';

and if you want the target file as small as possible (at the expense of a longer
compression time) then add:

 $entry->desiredCompressionLevel(9);

after the call to addFile and before writeToFileNamed.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Archive Zip

2006-09-12 Thread Derek B. Smith


--- Tom Phoenix <[EMAIL PROTECTED]> wrote:

> On 9/11/06, Derek B. Smith
> <[EMAIL PROTECTED]> wrote:
> 
> > I need to compress a bunch of files, so instead of
> > making a system call to gzip I figured to try out
> > Archive::Zip.
> > After running this code it creates a new file but
> is
> > larger in size.
> 
> That module automatically uses Compress::Zlib to
> compress the data.
> Were any of the files compressed before you started?
> Compression
> algorithms can't shrink every file, and files that
> have compact
> formats can't be shrunk. If you try collecting the
> files with another
> archiving tool, you should see roughly the same
> results, if they're
> already compact: The archive will be roughly the
> same size as the
> uncompressed data, or a little larger.
> 
> Cheers!
> 
> --Tom Phoenix

**
Thank you 4 replying!.
The files attributes prior to using gzip were:
-rw-r--r--   1 root   sys9007879 Sep 11
15:24 derek.log

after compression using gzip are:
-rw-r--r--   1 root   sys 393013 Sep 11
15:24 derek.log.gz

as you can see this file was compressed significantly
as it is a large text based file:
#>file derek.log
derek.log:  ascii text

Is this code syntactically correct to produce a zipped
file ?  I read the POD and there are no clear
examples. Please help...thank you
derek


#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use Readonly;
use Archive::Zip qw ( :ERROR_CODES :CONSTANTS );

my $zip = Archive::Zip->new();

# add all readable files and directories
  $zip->addTree( '/usr/local/admin', 'derek' );
  # and write them into a file
  $zip->writeToFileNamed('xxx.zip');



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