Re: How to make a resource intensive script less intensive.

2001-07-08 Thread Jim Conner

I decided to go ahead and use File::Tail.  it works like a champ.  However, 
writing my own was quite helpful (or atleast tweaking my own ;))

Thanks all.

- Jim

At 04:31 PM 7/8/2001 -0400, Walt Mankowski wrote:
>On Sun, Jul 08, 2001 at 02:20:40PM -0400, Jim Conner wrote:
> > I am writing a script that is quite cool imo once I get it done.  But
> > already I am seeing that it takes a ton of system resources.  Simply put,
> > the script watches a log file (like tail -f) and then reacts to certain
> > things that occur.  I am thinking that the loop that it is in might be
> > taking up all the resources but that doesn't quite jive with my knowledge
> > of how this kind of thing works.  Here is a snippet of the resource usage
> > from top(3):
>
>You're using up all those resources because your program is sitting in
>a hard loop.  Try inserting a sleep at the bottom of your outer for
>loop.  You might also want to take a look at "How do I do a 'tail -f"
>in perl?' in perlfaq5.
>
>Walt



- Jim

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861

-BEGIN PERL GEEK CODE BLOCK-  --BEGIN GEEK CODE BLOCK--
Version: 0.01 Version: 3.12
P++>*@$c?P6?R+++>@$M  GIT/CM/J d++(--) s++:++ a-
 >$O!MA->E!> PU-->+++BDC(+) UB$L$S$
$C-@D!>(-)$S@$X?WP+>MO!>+++   P++(+)>+ L+++()>+$ !E*
+PP+++>n-CO?PO!o >G   W++(+++) N+ o !K w--- PS---(-)@ PE
 >*(!)$A-->@$Ee---(-)Ev++uL++>*@$uB+   Y+>+++ PGP t+(+++)>+++@ 5- X++ R@
 >*@$uS+>*@$uH+uo+w-@$m!   tv+ b? DI-(+++) D+++(++) G()
--END PERL GEEK CODE BLOCK--  --END GEEK CODE BLOCK--




Concurrency

2001-07-08 Thread Ryan Boder


Hi,

I am very new to perl. In fact, I am trying to write my first perl app 
ever. I would like it to do peer to peer networking. I have always been 
a C programmer and if I wanted to do this in C I would use threads and 
have one accepting connections and one initiating connections. Well, I 
read that thread support for perl was experimental and you had to 
recompile perl to include a thread.pm module. I really don't want to do 
that since not very many people would then want to use my program. Also 
I read that using fork was a bad idea when trying to write portable code.

So what would be the best way to be able to both accept and initiate 
network connections in perl? I want it to be portable. I assume some 
kind of concurrency would be needed but then again I havce only been 
using perl for a week.

Thanks,
Ryan




Re: foreach examples/usage

2001-07-08 Thread mcrawley

Sounds interesting.  Please verify this link.
-- Original Message --
From: "Jos I. Boumans" <[EMAIL PROTECTED]>
Date: Sun, 8 Jul 2001 11:19:21 +0200

>
>you might find the loops/block tutorial i wrote on
>www.sharemation.com/~perl/tut helpfull
>
>regards,
>
>Jos Boumans
>
>
>I am trying to learn the foreach loop. Is there a place on the web where
>there are examples for the foreach? Basically I have an array of X elements
>and I want to go from the first element (is it zero?) to the last. I have a
>variable containing the number of elements in the array. If the array has 22
>elements does it go from 0 to 21 or 1 to 22?
>
>
>

--
Michael L. Crawley, CIO
Business Strategy, E-Technology Specialist
Jenai Communications
P.O. Box 33
Wheeling, Illionis 60090
(847) 745 - 0940
http://www.jenaipower.net
mailto:[EMAIL PROTECTED]

--



Re: How to make a resource intensive script less intensive.

2001-07-08 Thread Jim Conner

Excellent!  I will check that out!

- Jim

At 04:31 PM 7/8/2001 -0400, Walt Mankowski wrote:
>On Sun, Jul 08, 2001 at 02:20:40PM -0400, Jim Conner wrote:
> > I am writing a script that is quite cool imo once I get it done.  But
> > already I am seeing that it takes a ton of system resources.  Simply put,
> > the script watches a log file (like tail -f) and then reacts to certain
> > things that occur.  I am thinking that the loop that it is in might be
> > taking up all the resources but that doesn't quite jive with my knowledge
> > of how this kind of thing works.  Here is a snippet of the resource usage
> > from top(3):
>
>You're using up all those resources because your program is sitting in
>a hard loop.  Try inserting a sleep at the bottom of your outer for
>loop.  You might also want to take a look at "How do I do a 'tail -f"
>in perl?' in perlfaq5.
>
>Walt



- Jim

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861

-BEGIN PERL GEEK CODE BLOCK-  --BEGIN GEEK CODE BLOCK--
Version: 0.01 Version: 3.12
P++>*@$c?P6?R+++>@$M  GIT/CM/J d++(--) s++:++ a-
 >$O!MA->E!> PU-->+++BDC(+) UB$L$S$
$C-@D!>(-)$S@$X?WP+>MO!>+++   P++(+)>+ L+++()>+$ !E*
+PP+++>n-CO?PO!o >G   W++(+++) N+ o !K w--- PS---(-)@ PE
 >*(!)$A-->@$Ee---(-)Ev++uL++>*@$uB+   Y+>+++ PGP t+(+++)>+++@ 5- X++ R@
 >*@$uS+>*@$uH+uo+w-@$m!   tv+ b? DI-(+++) D+++(++) G()
--END PERL GEEK CODE BLOCK--  --END GEEK CODE BLOCK--




RADIUS

2001-07-08 Thread Ryan Gralinski

Is there anything out there to authenticate a user with a perl script from
a radius server?

Ryan





Re: How to make a resource intensive script less intensive.

2001-07-08 Thread Jim Conner

Ok. So you are thinking it might be the loop then too?

TIA
- Jim


At 11:48 AM 7/8/2001 -0700, Sandor W. Sklar wrote:
>you might want to look at "swatch", by Todd Atkins, to see how it is done 
>there  ...
>
>
>
>There is a File::Tail module which might work for you as well, or, at 
>least show you another way to do it.
>
>-s-
>
>
>At 2:20 PM -0400 7/8/01, Jim Conner wrote:
>>I am writing a script that is quite cool imo once I get it done. But 
>>already I am seeing that it takes a ton of system resources. Simply put, 
>>the script watches a log file (like tail -f) and then reacts to certain 
>>things that occur.  I am thinking that the loop that it is in might be 
>>taking up all the resources but that doesn't quite jive with my knowledge 
>>of how this kind of thing works.  Here is a snippet of the resource usage 
>>from top(3):
>>
>>Swap:  34236K av,   7268K used,  26968K free 35756K cached
>>
>>   PID USER PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
>>  8400 qadmin17   0  3560 3560  1404 R   0 98.8  5.6   0:28 perl
>>
>>
>>Here is a snippet of the part of the code that does the tail -f:
>>
>>
>>if ( !chdir($qlogdir) ) {
>> print "Cannot read $qlogdir: $!\n";
>> return(undef);
>>} else {
>> my $curpos;
>>
>> &dmsg( __LINE__,
>>   "Reading at end of Quake logfile: $qlogfile\n");
>>
>> open(QLOG,$qlogfile)
>> or die("Unable to open $qlogfile: $!\n");
>>
>> while (  ) {
>> $curpos++;
>> }
>>
>> &dmsg( __LINE__, "Cursor Pos: $curpos\n");
>>
>> # Following tail -f code provided by http://www.PerlMonks.org
>> # Monk unknown.
>>
>> for ( ; ; ) {
>>my $vip   = 0;  # vote in progress
>> my $input;
>> my $timestart;  # Leave this here
>> # until I know I dont
>> # need it.
>>  my $timestop;
>> my $player_name;
>> my $reqed_map;
>> my $command;
>>
>> for ( $curpos = tell(QLOG) ;
>>   $input  =  ;
>>   $curpos = tell(QLOG) ) {
>> chomp $input;
>>
>> if ( defined $input ) {
>> &dmsg( __LINE__,"$input\n");
>> } else {
>> &dmsg( __LINE__,
>>basename($qlogfile) . " : EMPTY SET!\n");
>> }
>>
>> $_  = $input;
>>
>> ## START OUR SWITCH BLOCK!
>>
>> switch: {
>>
>> ##
>> # This next block for map voting.
>> ##
>>
>>   /.*] (.*): \!$keyword_map/ && do {
>> $input   =~ /] (.*): \!($keyword_map) 
>> ([a-zA-Z0-9].*)/;
>>($player_name,
>> $command,
>> $reqed_map  )= ($1,$2,$3);
>> my $current_map  = ¤t_map;
>>
>> if ( !defined $reqed_map && $player_name ne 
>> /[Cc]onsole/ ) {
>>   &usage("vote_assist");
>> } else {
>> # This is where we decide what kind of vote 
>> we are
>> # in.  See comments.
>>
>> if ( $vote_type == 0 ) {
>> &type_votemap($reqed_map) if ( 
>> $current_map eq $vote_map );
>>
>> } elsif ( $vote_type == 2 ) {
>>  # check what map we are in here.
>> # then if we are in votemap, react :
>>  # or if we are in regular map, react
>> ( $current_map eq $vote_map ) ? 
>> &type_votemap   ($reqed_map):
>>&type_no_votemap($reqed_map);
>> }
>>
>> sub type_votemap($) {
>>my $funcName = (caller(0))[3];
>>my $reqed_map=  shift;
>>
>>print STDERR "Now in $funcName\n";
>># This section will work in votemap ONLY and
>># players can only vote during this map.
>>&map_vote($player_name,0,$reqed_map);
>> }
>>
>> sub type_no_votemap($) {
>> my $funcName = (caller(0))[3];
>> my $reqed_map=  shift;
>>
>> print STDERR "Now in $funcName\n";
>> # This section will work in any map and
>> # players can vote anytime during play.
>> # Must use vote session.
>> print STDERR "Requested map is: 
>> $reqed_map from $funcName\n";
>>   

Re: How to make a resource intensive script less intensive.

2001-07-08 Thread Walt Mankowski

On Sun, Jul 08, 2001 at 02:20:40PM -0400, Jim Conner wrote:
> I am writing a script that is quite cool imo once I get it done.  But 
> already I am seeing that it takes a ton of system resources.  Simply put, 
> the script watches a log file (like tail -f) and then reacts to certain 
> things that occur.  I am thinking that the loop that it is in might be 
> taking up all the resources but that doesn't quite jive with my knowledge 
> of how this kind of thing works.  Here is a snippet of the resource usage 
> from top(3):

You're using up all those resources because your program is sitting in
a hard loop.  Try inserting a sleep at the bottom of your outer for
loop.  You might also want to take a look at "How do I do a 'tail -f"
in perl?' in perlfaq5.

Walt




Re: How to make a resource intensive script less intensive.

2001-07-08 Thread Sandor W. Sklar

you might want to look at "swatch", by Todd Atkins, to see how it is 
done there  ...



There is a File::Tail module which might work for you as well, or, at 
least show you another way to do it.

-s-


At 2:20 PM -0400 7/8/01, Jim Conner wrote:
>I am writing a script that is quite cool imo once I get it done. 
>But already I am seeing that it takes a ton of system resources. 
>Simply put, the script watches a log file (like tail -f) and then 
>reacts to certain things that occur.  I am thinking that the loop 
>that it is in might be taking up all the resources but that doesn't 
>quite jive with my knowledge of how this kind of thing works.  Here 
>is a snippet of the resource usage from top(3):
>
>Swap:  34236K av,   7268K used,  26968K free 35756K cached
>
>   PID USER PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
>  8400 qadmin17   0  3560 3560  1404 R   0 98.8  5.6   0:28 perl
>
>
>Here is a snippet of the part of the code that does the tail -f:
>
>
>if ( !chdir($qlogdir) ) {
> print "Cannot read $qlogdir: $!\n";
> return(undef);
>} else {
> my $curpos;
>
> &dmsg( __LINE__,
>   "Reading at end of Quake logfile: $qlogfile\n");
>
> open(QLOG,$qlogfile)
> or die("Unable to open $qlogfile: $!\n");
>
> while (  ) {
> $curpos++;
> }
>
> &dmsg( __LINE__, "Cursor Pos: $curpos\n");
>
> # Following tail -f code provided by http://www.PerlMonks.org
> # Monk unknown.
>
> for ( ; ; ) {
>my $vip   = 0;  # vote in progress
> my $input;
> my $timestart;  # Leave this here
> # until I know I dont
> # need it.
>  my $timestop;
> my $player_name;
> my $reqed_map;
> my $command;
>
> for ( $curpos = tell(QLOG) ;
>   $input  =  ;
>   $curpos = tell(QLOG) ) {
> chomp $input;
>
> if ( defined $input ) {
> &dmsg( __LINE__,"$input\n");
> } else {
> &dmsg( __LINE__,
>basename($qlogfile) . " : EMPTY SET!\n");
> }
>
> $_  = $input;
>
> ## START OUR SWITCH BLOCK!
>
> switch: {
>
> ##
> # This next block for map voting.
> ##
>
>   /.*] (.*): \!$keyword_map/ && do {
> $input   =~ /] (.*): \!($keyword_map) 
>([a-zA-Z0-9].*)/;
>($player_name,
> $command,
> $reqed_map  )= ($1,$2,$3);
> my $current_map  = ¤t_map;
>
> if ( !defined $reqed_map && $player_name ne 
>/[Cc]onsole/ ) {
>   &usage("vote_assist");
> } else {
> # This is where we decide what kind of vote we are
> # in.  See comments.
>
> if ( $vote_type == 0 ) {
> &type_votemap($reqed_map) if ( 
>$current_map eq $vote_map );
>
> } elsif ( $vote_type == 2 ) {
>  # check what map we are in here.
> # then if we are in votemap, react :
>  # or if we are in regular map, react
> ( $current_map eq $vote_map ) ? 
>&type_votemap   ($reqed_map):
> 
>&type_no_votemap($reqed_map);
> }
>
> sub type_votemap($) {
>my $funcName = (caller(0))[3];
>my $reqed_map=  shift;
>
>print STDERR "Now in $funcName\n";
># This section will work in votemap ONLY and
># players can only vote during this map.
>&map_vote($player_name,0,$reqed_map);
> }
>
> sub type_no_votemap($) {
> my $funcName = (caller(0))[3];
> my $reqed_map=  shift;
>
> print STDERR "Now in $funcName\n";
> # This section will work in any map and
> # players can vote anytime during play.
> # Must use vote session.
> print STDERR "Requested map is: 
>$reqed_map from $funcName\n";
> $vip= &map_vote($player_name,1,
> $reqed_map   );
> }
>
> }
> };
>last switch;
>
> 

Re: Executing Remote Script with parameters

2001-07-08 Thread Luke Bakken

I would investigate using rsh or (peferably) ssh to execute the remote
script.

if you had an account on machine 'foo', you can use RSA or DSA
authentication to avoid needing a password to execute a script on foo, but
this isn't an SSH group, so if you need more info, email me.

there's also a Net::SSH module, if I'm not mistaken.


On Sun, 8 Jul 2001, Suresh Babu.A [Support] wrote:

>
> Ladies and Gentlemen,
>
> I am executing a script from the client, which should internally call a
> script of a remote server and i have to pass argument from the client. Any
> help regarding this is much appreticated.
>
> Thank you very much for your time.
>
> SureshA
> [EMAIL PROTECTED]
>




How to make a resource intensive script less intensive.

2001-07-08 Thread Jim Conner

I am writing a script that is quite cool imo once I get it done.  But 
already I am seeing that it takes a ton of system resources.  Simply put, 
the script watches a log file (like tail -f) and then reacts to certain 
things that occur.  I am thinking that the loop that it is in might be 
taking up all the resources but that doesn't quite jive with my knowledge 
of how this kind of thing works.  Here is a snippet of the resource usage 
from top(3):

Swap:  34236K av,   7268K used,  26968K free 35756K cached

   PID USER PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
  8400 qadmin17   0  3560 3560  1404 R   0 98.8  5.6   0:28 perl


Here is a snippet of the part of the code that does the tail -f:


if ( !chdir($qlogdir) ) {
 print "Cannot read $qlogdir: $!\n";
 return(undef);
} else {
 my $curpos;

 &dmsg( __LINE__,
   "Reading at end of Quake logfile: $qlogfile\n");

 open(QLOG,$qlogfile)
 or die("Unable to open $qlogfile: $!\n");

 while (  ) {
 $curpos++;
 }

 &dmsg( __LINE__, "Cursor Pos: $curpos\n");

 # Following tail -f code provided by http://www.PerlMonks.org
 # Monk unknown.

 for ( ; ; ) {
my $vip   = 0;  # vote in progress
 my $input;
 my $timestart;  # Leave this here
 # until I know I dont
 # need it.
  my $timestop;
 my $player_name;
 my $reqed_map;
 my $command;

 for ( $curpos = tell(QLOG) ;
   $input  =  ;
   $curpos = tell(QLOG) ) {
 chomp $input;

 if ( defined $input ) {
 &dmsg( __LINE__,"$input\n");
 } else {
 &dmsg( __LINE__,
basename($qlogfile) . " : EMPTY SET!\n");
 }

 $_  = $input;

 ## START OUR SWITCH BLOCK!

 switch: {

 ##
 # This next block for map voting.
 ##

   /.*] (.*): \!$keyword_map/ && do {
 $input   =~ /] (.*): \!($keyword_map) 
([a-zA-Z0-9].*)/;
($player_name,
 $command,
 $reqed_map  )= ($1,$2,$3);
 my $current_map  = ¤t_map;

 if ( !defined $reqed_map && $player_name ne 
/[Cc]onsole/ ) {
   &usage("vote_assist");
 } else {
 # This is where we decide what kind of vote we are
 # in.  See comments.

 if ( $vote_type == 0 ) {
 &type_votemap($reqed_map) if ( 
$current_map eq $vote_map );

 } elsif ( $vote_type == 2 ) {
  # check what map we are in here.
 # then if we are in votemap, react :
  # or if we are in regular map, react
 ( $current_map eq $vote_map ) ? 
&type_votemap   ($reqed_map):
 
&type_no_votemap($reqed_map);
 }

 sub type_votemap($) {
my $funcName = (caller(0))[3];
my $reqed_map=  shift;

print STDERR "Now in $funcName\n";
# This section will work in votemap ONLY and
# players can only vote during this map.
&map_vote($player_name,0,$reqed_map);
 }

 sub type_no_votemap($) {
 my $funcName = (caller(0))[3];
 my $reqed_map=  shift;

 print STDERR "Now in $funcName\n";
 # This section will work in any map and
 # players can vote anytime during play.
 # Must use vote session.
 print STDERR "Requested map is: $reqed_map 
from $funcName\n";
 $vip= &map_vote($player_name,1,
 $reqed_map   );
 }

 }
 };
last switch;

 ## END OF SWITCH BLOCK!

 if ( $vip ) {
 # Set my timestop (time limit for an active vote)
 ($timestart,
  $timestop) = &get_seconds();
  print "Timestart is: $timestart and " .
"timestop is: $timestop\n";
 }

 }

  

Re: foreach examples/usage

2001-07-08 Thread Jos I. Boumans

link works.. but it's on a free server (sharemation) so sometimes the server
is down...
i should have my own up shortly, at japh.nu... just have to fiddle with the
dns entry... =)

Jos

- Original Message -
From: "mcrawley " <[EMAIL PROTECTED]>
To: "Evan Panagiotopoulos" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
"Jos I. Boumans" <[EMAIL PROTECTED]>
Sent: Sunday, July 08, 2001 4:39 PM
Subject: Re: foreach examples/usage


> Sounds interesting.  Please verify this link.
> -- Original Message --
> From: "Jos I. Boumans" <[EMAIL PROTECTED]>
> Date: Sun, 8 Jul 2001 11:19:21 +0200
>
> >
> >you might find the loops/block tutorial i wrote on
> >www.sharemation.com/~perl/tut helpfull
> >
> >regards,
> >
> >Jos Boumans
> >
> >
> >I am trying to learn the foreach loop. Is there a place on the web where
> >there are examples for the foreach? Basically I have an array of X
elements
> >and I want to go from the first element (is it zero?) to the last. I have
a
> >variable containing the number of elements in the array. If the array has
22
> >elements does it go from 0 to 21 or 1 to 22?
> >
> >
> >
>
> --
> Michael L. Crawley, CIO
> Business Strategy, E-Technology Specialist
> Jenai Communications
> P.O. Box 33
> Wheeling, Illionis 60090
> (847) 745 - 0940
> http://www.jenaipower.net
> mailto:[EMAIL PROTECTED]
>
> --
>




Re: Module to Parse MIME-encoded Email?

2001-07-08 Thread M.W. Koskamp


- Original Message -
From: Mike Miller <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 07, 2001 6:08 PM
Subject: Module to Parse MIME-encoded Email?


>
> Gurus:
>
> As a learning exercise I'm writing my own web-based POP3 client, and
> wish to be able to handle emails which are MIME-encoded.  So I'm looking
> for perhaps a module which will take the full message, give me back
> headers I want, and parse the body and return it in a form that could
> be dumped straight to the browser.  (At the very least, a module to which
> I could feed the MIME-encoded body would be nice, as I can parse the
> headers myself).

Try Mime::Parser.
That might do what you want.
I think it can handle both Base64 and UUencoded messages (beware that
outlook express has some different way in adding padding characters and
things).

Maarten.




Re: foreach examples/usage

2001-07-08 Thread Jos I. Boumans


you might find the loops/block tutorial i wrote on
www.sharemation.com/~perl/tut helpfull

regards,

Jos Boumans


I am trying to learn the foreach loop. Is there a place on the web where
there are examples for the foreach? Basically I have an array of X elements
and I want to go from the first element (is it zero?) to the last. I have a
variable containing the number of elements in the array. If the array has 22
elements does it go from 0 to 21 or 1 to 22?