Re: Generic database access?

2003-09-29 Thread Mark G
Rob,

why not try one of r-desktops. I use TridiaVNC, which you can carry with
ssh.

Mark G
- Original Message - 
From: "Rob Richardson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 29, 2003 3:33 PM
Subject: Re: Generic database access?


> Sam,
>
> There's a lot of products named "Webmon".  The ones I found on Google
> didn't do what I want.  Which one are you thinking of?  Can you give me
> a company name?
>
> Thanks again!
>
> Rob
>
>
>
> __
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: make CPAN::Shell->i; print to a filehandle

2003-06-30 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 30, 2003 4:52 PM
Subject: Re: make CPAN::Shell->i; print to a filehandle


> [EMAIL PROTECTED] writes:
>
> > There is no point of arguing over this { After all this is a
> > friendly group },but I think thats where you had a misunderstanding
> > of your formulation in the first place. The problem as translated {
> > by final result } was how can I redirect the output of a runing
> > process.
>
> Yup, nuf said on that front.   You've been very patient.
> And its nearly always true that my programming suffers from confusion
> all along the way.
>
> What do you think of this method?... It's snipped down quite a lot
> but you can still see the idea.

Ok I am diving in.
>
> I tried to explain what I think is happening in my comments but not
> sure I really got it right.
thats ok, I always try to get it down on paper first though. Need a flow
chart other wise things always get messY.

> A whole series of other getops choices
> are snipped for clarity:
>
> #!/usr/local/bin/perl -w
>
> # [...]
> # [snipped gobs of tests and file checks]
> # [...]
> use CPAN;
> use vars qw($opt_r $opt_i $opt_m $opt_b $opt_d $opt_a);
> use Getopt::Std;
> my $optstr ="ra:b:d:i:m:";
> getopts($optstr);
>
> ## Build or refresh the local database
> if($opt_r){
>   if($ARGV[0]){
>  usage();
>  print "No arguments allowed with -r flag\n";
>  exit;
>   }
> # Start another instance of this script (Fork)
> # and connect the standard output of the child process to the file
> # handle specified. See the entry for the open() function in perlfunc, and
> # perlipc for plenty of info.
>   my $pid = open(CPAN_I, "-|");
>   die "Cannot fork: $!" if not defined $pid;
>
> ## If the fork worked... run  our data collector.
>   if ($pid == 0){ # child
> CPAN::Shell->i;
> exit 0;
>   }
>
> ## While its running print it to disk
>   open(FH,">$target")or die "Cannot open $target: $!";
>   print "\n   Refreshing/Creating $target...\n";
>   while(){
> print FH $_;
>   }
>   close(FH);
>   ## Shut down the fork.
>   close CPAN_I or warn "child exited: $?";
> }
>
> # [...]
>
> sub usage {
>print<
> Purpose: Search an on disk copy of cpan holdings
>  (listed by Author Module Distribution and Bundle)
> Usage: \`$myscript [-r ]  -[abdmi] \"REGEX\"'
> Flags: -a search Author section for REGEX
>-b search Bundle section for REGEX
>-d " ditto " Distribution section
>-m " ditto " Module section
>-i  All of above
> Special:
>-r can only be used by itself and is used to refresh or
>   create the on disk copy of cpan information.
>   (Defaults to /usr/local/cpan/cpan_dat/combo_list.dat)
> NOTES:
>   Consider that with -[abdmi] flags the supplied REGEX will be
>   inserted after some default settings I.E.:
>   ^DEFAULT_STRING +REGEX
>   So to look for somethiong deeper in a line .. use:
>\`$myscript  -[abdmi] ".*REGEX" '
>
> EOM
> }
>
Cool, that should work. You will loose some noticable time if you are going
to install 10 or so modules. This is primary due to: spawning on each child
and reastablishing TCP connection. But it does the job :O)

Mark G.

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



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



Re: make CPAN::Shell->i; print to a filehandle

2003-06-29 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: "Mark G" <[EMAIL PROTECTED]>
Cc: "perl" <[EMAIL PROTECTED]>
Sent: Sunday, June 29, 2003 4:37 PM
Subject: Re: make CPAN::Shell->i; print to a filehandle


> Mark G <[EMAIL PROTECTED]> writes:
>
> > Well I just tryed runing  'CPAN::Shell->i' from the shell, and it failed
to
> > launch it. Can you run  'CPAN::Shell->i' from your systems default shell
??
> > you can try using ppm instead.
>
> Ahh I guess it doesn't know about `use CPAN' in the parent script.

well you should of included that in your original post.
>
> But that was the whole point.. to run CPAN::Shell->i from inside a
> script and process the output.
>
> From the command line:
>
>   perl -e 'use CPAN;CPAN::Shell->i'
>
> works here, to get the output.
>
> From perldoc it appears that something like this should work but it
> doesn't either:
> my ($wtr, $wdr, $err, @item, $pid);
>
> $pid = open2($wtr, $rdr,  'perl -e ', 'use CPAN;',  'CPAN::Shell->i;');

 this should be

   $pid = open2(  $wtr, $rdr, ' perl -e 'use CPAN;CPAN::Shell->i' ');

>
> foreach(@item){
>   print $wtr "$_\n";
>   print "shell output: $_\n" while <$rdr>;
> }
>

hth,
Mark g
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: make CPAN::Shell->i; print to a filehandle

2003-06-29 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 29, 2003 11:58 AM
Subject: Re: make CPAN::Shell->i; print to a filehandle


> Mark G <[EMAIL PROTECTED]> writes:
>
> > that would be
> >
> > $pid = open2($wtr, $rdr, 'CPAN::Shell->i');
> >
> > foreach( @module ){
> > print $wtr "$_\n";
> > print "shell output: $_\n" while <$rdr>;
> > }
>
> Still not able to get this to fly.  Probably something wrong here:
>
> cat IPC.pl
> #!/usr/local/bin/perl -w
>
> use CPAN;
> use IPC::Open2;
>
> my ($wtr, $wdr, @item, $pid);
>
> $pid = open2($wtr, $rdr, 'CPAN::Shell->i');
>
> foreach(@item){
>   print $wtr "$_\n";
>   print "shell output: $_\n" while <$rdr>;
> }
>
>  ./IPC.pl
> sh: CPAN::Shell-: command not found
>
> With out the single quotes around CPAN::Shell->i:
>
> It runs and kicks out everything on cpan, but doesn't do any of the
> read write stuff.  Closing with this error:
>
> [...]
> 28213 items found
> Can't exec "1": No such file or directory at
> /usr/local/lib/perl5/5.8.0/IPC/Open3.pm line 230.  open2: exec of 1
> failed at ./IPC.pl line 8
>
> For some reason it seems to be using:
>   /usr/local/lib/perl5/5.8.0/IPC/Open3.pm
> Instead of:
> /usr/local/lib/perl5/5.8.0/IPC/Open2.pm
>
> I tried changine over to IPC::Open3
>
> cat IPC.pl
> #!/usr/local/bin/perl -w
>
> use CPAN;
> use IPC::Open3;
>
> my ($wtr, $wdr, $err, @item, $pid);
>
> $pid = open3($wtr, $rdr, $err, 'CPAN::Shell->i');
>
> foreach(@item){
>   print $wtr "$_\n";
>   print "shell output: $_\n" while <$rdr>;
> }
>
> This runs but exits instantly with no error and does nothing
> noticable.

Well I just tryed runing  'CPAN::Shell->i' from the shell, and it failed to
launch it. Can you run  'CPAN::Shell->i' from your systems default shell ??
you can try using ppm instead.

Mark G

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



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



Re: refs to hashes

2003-06-29 Thread Mark G
Thanks Kevin, that did it.

Mark G.

- Original Message - 
From: "Kevin Pfeiffer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 29, 2003 5:45 AM
Subject: Re: refs to hashes


> In article <[EMAIL PROTECTED]>, Mark G wrote:
>
> > Hi All,
> >
> > I need to read in some data and put it into a data structure ex:
> >
> > knife #product name
> > 3  #quantity
> > 1  #price
> >
> > I would like to hold in as a hash referancing other hashes ex:
> > $ref=read_data();
> >
> >
> >
> > sub read_data{
> > open $RD,"< value.dat" || print "could not process request\n";
> >
> > while( chomp ( $product   = <$RD> ) ){
> > chomp ( $quantity = <$RD> );
> > chomp ( $price = <$RD> );
> >
> >  $inventory{$product}={
> >quantity=> $quantityr,
> >price => $price
> >   };
> > }
> >
> > return \%inventory;
> > }
> >
> > now how can I access the elements for example:
> >
> > foreach( sort keys %{ $ptr } ){
> >  print the quantity and price of each product
> >  if a given product exist print its price
> > }
>
> Here is what I came up with:
> sub price_list {
>my $ref = shift;
>my $format = "%15s%4s%5.2f \n";
>printf "%15s %4s%5s\n\n", "Product Name", "Qty.", "Price";
>foreach my $product ( sort keys %{ $ref } ){
>
>   printf $format, $product, $ref->{$product}{quantity},
$ref->{$product}{price};
>
>   # If ea. product has lots of attributes, this add'l loop pulls the
>   # values for all keys, but you might have to modify order (store
>   # attribute names in an ordered array)?
>   #  my @line;
>   #  push @line, $product;
>   #  foreach( keys %{ $ref->{$product} } ){
>   # push @line, $ref->{$product}{ $_ };
>   #  }
>   #  printf $format, @line;
>
>} # end of product loop
> }
>
> (Disclaimer - just trying this myself - no warranty)
> -- 
> Kevin Pfeiffer
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



refs to hashes

2003-06-29 Thread Mark G
Hi All,

I need to read in some data and put it into a data structure ex:

knife #product name
3  #quantity
1  #price

I would like to hold in as a hash referancing other hashes ex:
$ref=read_data();



sub read_data{
open $RD,"< value.dat" || print "could not process request\n";

while( chomp ( $product   = <$RD> ) ){
chomp ( $quantity = <$RD> );
chomp ( $price = <$RD> );

 $inventory{$product}={ 
   quantity=> $quantityr,
   price => $price
  };
}

return \%inventory;
}

now how can I access the elements for example:

foreach( sort keys %{ $ptr } ){
 print the quantity and price of each product
 if a given product exist print its price
}
 
Thanx in Advance,
Mark Goland





Re: make CPAN::Shell->i; print to a filehandle

2003-06-28 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 28, 2003 7:18 PM
Subject: Re: make CPAN::Shell->i; print to a filehandle


> Mark G <[EMAIL PROTECTED]> writes:
> 
> 
> >> $target = "somefile";
> >> if($opt_r){
> >>   open(FH,">$target") or die "Cannot open $target: $!";  
> >> print FH CPAN::Shell->i;  
> > you can try IPC::Open2.
> 
> That looks like the stuff.  Apparently the pod author felt it was
> criminal to supply even a very basic example.   Thereby creating a
> situation where anyone not already a programmer must stumble around
> endlessly trying to figure out the syntax to get some use of it.

This is posix stuff mostly

> 
> I really do appreciate those few outlaws who put usefull examples in
> the documentation.

why not if u got time

> 
> Its not clear to me what to do after this:
> $pid = open2($wtr, $rdr, 'CPAN::Shell->i');
> 
> while(){
>   print AND_HERE "$_\n";
> }

that would be

$pid = open2($wtr, $rdr, 'CPAN::Shell->i');

foreach( @module ){
print $wtr "$_\n";
    print "shell output: $_\n" while <$rdr>;
}

> FH is not normally represented as a scalar variable.
you can do that

> What role does $pid play?
you can get exit status,error,signal of the child


hth,

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


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



Re: make CPAN::Shell->i; print to a filehandle

2003-06-28 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 28, 2003 2:20 AM
Subject: make CPAN::Shell->i; print to a filehandle


> How do I go about making the output from 
> CPAN::Shell->i; go into a file handle
> Instead of STDOUT like it does in this formulation:
> 
> $target = "somefile";
> if($opt_r){
>   open(FH,">$target") or die "Cannot open $target: $!";  
> print FH CPAN::Shell->i;  
you can try IPC::Open2.

Mark g

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


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



Re: perldoc - html format ?

2003-06-20 Thread Mark G
HI Janek,

This doesnt seem to work on my Active perl 5.8.

Mark G
- Original Message - 
From: "Janek Schleicher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 20, 2003 3:28 PM
Subject: Re: perldoc - html format ?


> Jeff Westman wrote at Fri, 20 Jun 2003 11:33:59 -0700:
> 
> > Is it possible to reformat a perldoc in HTML format?
> > I don't see this as an option to 'perldoc'.
> 
> From
> perldoc perldoc
>-o output-formatname
> This specifies that you want Perldoc to try using a
> Pod-formatting class for the output format that you
> specify.  For example: "-oman".  This is actually
> just a wrapper around the "-M" switch; using
> "-oformatname" just looks for a loadable class by
> adding that format name (with different
> capitalizations) to the end of different classname
> prefixes.
> 
> For example, "-oLaTeX" currently tries all of the
> following classes: Pod::Perldoc::ToLaTeX
> Pod::Perldoc::Tolatex Pod::Perldoc::ToLatex
> Pod::Perldoc::ToLATEX Pod::Simple::LaTeX
> Pod::Simple::latex Pod::Simple::Latex
> Pod::Simple::LATEX Pod::LaTeX Pod::latex Pod::Latex
> Pod::LATEX.
> 
> So, if you want to see it in HTML output,
> just try something like
> perldoc -oHMTL perldoc
> 
> 
> Greetings,
> Janek
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: Can LWP::Simple tranfer image urls?

2003-06-20 Thread Mark G
O BoY, These are deffinitly Camel girls 

Mark
- Original Message - 
From: "zentara" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 20, 2003 3:08 PM
Subject: Re: Can LWP::Simple tranfer image urls?


> On Fri, 20 Jun 2003 09:09:21 EDT, [EMAIL PROTECTED] wrote:
>
> >Do I need to change the http header for transfering image urls?  I get
errors
> >when I transfer a jpg:
> >picture cannot be displayed because it contains errors.
>
> It works well for me on linux.
> This is one of my favorite scripts by Merlyn. :-)
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> $|++;
>
> use LWP::Simple;
>
> my @models = qw(amy aurelie daniela elsa fernanda
> heidi josie lujan michelle molly noemie shakara
> shirley veronica yamila);
>
> for my $model (@models) {
> for my $id (1..9) {
> my $url = sprintf
>
"http://sportsillustrated.cnn.com/features/2001/swimsuit/gallery/%s/%s_%d_lg
.jpg",$model,
> $model, $id;
> my $file = "$model-$id.jpg";
> print "$url => $file: ";
> print +mirror($url, $file), "\n";
> }
> }
> __END__
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Getopt::Simple

2003-06-20 Thread Mark G

- Original Message - 
From: "Paul Kraus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 19, 2003 10:20 AM
Subject: Getopt::Simple


> What does env, and order do when using this module?
well who knows what it does, since you only send in a hash declaring it.
if -- is passed in the command line $help{env} will be set by getopt.
>
> 'help' =>
> {
> 'type'  => '',
> 'env'   => '--',
> 'default'   => '',
> #   'verbose'   => '',  # Not needed on every key.
> 'order' => 1,
> },
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Mark G.



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



Re: a real novice question about long filenames on win32

2003-06-18 Thread Mark G

...
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFolder = objFSO.GetFolder("C:\Media\Music\faves")
> Set colFiles = objFolder.Files
> For Each objFile in colFiles
>  fileName = objFSO.GetFileName(objFile)
>  newFileName = Right(fileName, Len(fileName)-5)
>  newFileName = Left(newFileName, Len(newFileName)-4)
>  arrayNewFileName = split(newFileName, " - ")
>  newFileName = arrayNewFileName(1) & " - " & arrayNewFileName(0) & ".mp3"
>  objFSO.CopyFile "C:\Media\Music\faves\" & fileName ,
"C:\Media\Music\palm\" & newFileName
>  'WScript.Echo newFileName
> Next
...

This looks nothing like a Cammel 

<~~~cut

$PATH=shift,$CONV_DIR=shift || die "convert.pl [dir-to-convert]
[destincation-DiR]\n";
 unless (-d $CONV_DIR){die "$PATH\t<== $!\n";}


 opendir NT, $PATH or die "$PATH\t<== $!\n";
 @FILES = readdir(NT) or die"ERROR:\t$!\n";
 @FILES = grep( !/^\.{1,2}/,@FILES );

print @FILES;

for( @FILES ){

#print "p=$PATH\td=$CONV_DIR\t$_";
 # open and creat new file
 open TMP,'<',"$PATH\\$_" || die "ERROR: $!\n";
 m/- (.*) - (.*)\./i;
 open WR,'>',"$CONV_DIR\\$2 - $1\.mp3" || die "ERROR: $!\n" if( $1 and $2);

 # copy your file over
 while(1){
   $char=sysread (TMP,$buff,4*2048) or last;
  syswrite WR,$buff,$char ||die "ERROR: $!\n";
 }

}


<~~~ paste

hth,
Mark G



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



Re: RE: Check if webserver is online

2003-06-17 Thread Mark G

- Original Message - 
From: "Jaschar Otto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 9:34 AM
Subject: RE: RE: Check if webserver is online


> >Howdy,
> >
> >> i own a webserver and i have  site on my
> >> own PC. I want that the visitors on my
> >> server website are able to see if my local PC
> >> is online. I've got linux,apache and ISDN on
> >> my own PC and i use a dyn dns tool so the
> >> IP is not the problem (i've got a
> >> somename.no-ip.com) adress.
> >>
> >> I want i.e. a small image displayed on my
> >> server website that tells me if this adress
> >> is reachable or not. the website is a single
> >> perl script so implementation is no problem
> >> but it should be as fast as possible.
> >>
> >> Any suggestions ?
> >
> >On server have a script that calls another script on your home machine
via LWP.
> >If it gets reply back display "I'm up and running" image
> >If not reply then display "I'm asleep now" image.
> >
> >HTH
> >
> >Dmuey
>
>
> Sorry, I don't like those 'two-scripts' solutions,
> i'd rather prefer something like 'ping' but i don't
> really know how to do that. I will try around with
> your suggestion but it's not really what i want.

You are right ping is the best way to know if the machine is connected to
the network. Search for ICMP on cpan

Mark G

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



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



Re: while (<>)

2003-06-16 Thread Mark G
- Original Message - 
From: "Bryan Harris" <[EMAIL PROTECTED]>
To: "Beginners Perl" <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 1:33 AM
Subject: Re: while (<>)


>
> >   #!/usr/bin/perl
> >
> >   my $showme = shift
> > or die "Usage: $0  [FILES]\n";
> >
> >   while (defined(my $line = <>)) {
> > $_ .= $line;
> > next unless eof; # [1]
> >
> > my $prefix = ($ARGV eq '-')? '' : "$ARGV: "; # [2]
> >
> > print "${prefix}$1\n" while /($showme)/mgi;
> > $_ = '';
> >   }
>
>
> Pretty neat, Steve, thanks.  The only thing that'd be nice to fix is
making
> it so it gives the usage line if you enter:
>
> % showme 'ah\d'
>
> instead of waiting for STDIN.  Aside from that it works perfectly.  And I
> learned a few things in the process.
you can do that by simply adding to second line:

my $showme = shift,@ARGV == 1  or die "Usage: $0  [FILES]\n";

This will stop:
% showme 'ah\d'
% showme 'ah\d' filee1 anything after


> Thanks again.
>
> - Bryan
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: Capture a printing function into an array

2003-06-16 Thread Mark G

- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 1:35 AM
Subject: Re: Capture a printing function into an array


> Mark G <[EMAIL PROTECTED]> writes:
>
> > I am a newbie as well but this line makes no sence to me why do you have
> > ($line = $line) ???
> >>   ($line  = $line)  =~ s/[Dd]estination/Dst/g;
>
> It began life as:
>$line  =~ s/[Dd]estination/Dst/g;
> Which is sufficient, but in the course of doggedly changing around
> all kinds of stuff as errors occured, it ended up in that unecessary
> condition.  This is not a finished product.

 I hear that.


> > Here you dont need to quote your variables
> > printf " %s %s %-28s %s\n", <$.>, $2, $4, $6;
> >
> > BTW why are you doing <$.> ??
>
> Is there something wrong with printing the line number?

Nothing @all. you dont need to do <$.>, $. is fine by it self so can scrap
that to
 printf " %s %s %-28s %s\n", $., $2, $4, $6;


> >>  if ($opt_l){
> >>   @c = sprintf(my_func());
> > sprintf will return a scalar, if you want an array you need to split
> >  @c = split "",sprintf(my_func());
>
> Good to know (about the scalar/array)but it does nothing for the
> stated problem.  That is, capturing the output rather than printing to
> stdout.  Your split doesn't do it either.
Ahh my fault, its getting a bit late must have misread something. printf
will default to STDOUT, you can change that by specifieng a filehnadle as
first argument to printf or usign the 2 arg verssion of select. In either
case that wont help { or atleast will make it a mess } your problem. I think
the simplest thing to do is to replace your printf with sprintf in your
function, like this:

sub my_func{
...
return sprintf " %s %s %-28s %s\n", $., $2, $4, $6;
}

and then you can assign to array:

@c = split "", my_func();

hTh,
Mark G

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



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



Re: Capture a printing function into an array

2003-06-16 Thread Mark G
- Original Message - 
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 16, 2003 11:47 PM
Subject: Capture a printing function into an array


>
> My script has a function that I want to just print its output in some
> circumstances but in others I need to capture its output into an
> array for further processing:
>
>   sub strip_to_bone {
>if(/[Ss]ource/ && /[Dd]estination/){
>   ($line = $line) =~ s/[Ss]ource/Src/g;
I am a newbie as well but this line makes no sence to me why do you have
($line = $line) ???
>   ($line  = $line)  =~ s/[Dd]estination/Dst/g;

same for this line

>  $line  =~ s/(^[^ ]+, )([0-9][^ ]+ [0-9][^ ]+)(.*)(Src[^ ]+
[0-9]+)(.*)(Dst[^ ]+ [0-9]+)/$2 $4 $6/;
>   $line = '';
>   printf " %s %s %-28s %s\n", "<$.>", "$2", "$4", "$6";

Here you dont need to quote your variables
printf " %s %s %-28s %s\n", <$.>, $2, $4, $6;

BTW why are you doing <$.> ??

>   }
> }
>
> I've tried various renditions of sprintf and eval but my syntax is
> still allowing the function to print to standard out.
>
> What is the correct way to do this so that the functions' output goes into
> an array (simplified below):
>
>  if ($opt_l){
>   @c = sprintf(my_func());
sprintf will return a scalar, if you want an array you need to split
 @c = split "",sprintf(my_func());

> #  @c = eval my_func();
>for (@c){
>  print "Got it =>  $_\n";
>}
> }
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

hTh,
Mark G



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



Re: Backup utility (was RE: concatonate to file?)

2003-06-16 Thread Mark G
> #make the archive:
> `tar -cvzf $targetpath $files`;

This to can be write in perl.

perldoc -m Archive::Tar
perldoc -m Compress::Zlib


- Original Message - 
From: "West, William M" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 16, 2003 3:08 PM
Subject: Backup utility (was RE: concatonate to file?)


> 
> #!/usr/bin/perl -w
> 
> #simple tar archiver... something to make a cron job with
> #in the future :)
> 
> 
> #thanks for the info for strftime :)  now can parse system time and
> #use it
> use POSIX qw(strftime);
> 
> # still unclear about '-w' verses 'use warnings'
> use strict;
> use diagnostics;
> 
> # where to put the archive::
> my $targetpath = "/tmp/databackup";
> #for timstamping filename:
> my $date = strftime("%A %B %C", localtime time);
> # files to archive:
> my $files = "/home/willy/tmp";
> 
> #parse the date information from strftime-- takes the data and
> #removes the spaces
> #$date=~ s/^(\S*\s\S*\s\S*).*/$1/s;
> #the above is no longer needed- was going to use 'date' untill Robin
> #Norwood set me straight :)
> #
> $date=~ s/\s//g;
> 
> #concatonate (thanks to rob and tim)
> $targetpath = $targetpath.$date.".bak";
> 
> print "path = $targetpath\n"; #debug
> 
> 
> #make the archive:
> `tar -cvzf $targetpath $files`;
> 
> 
> #thank you all :)
> #willy
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: updating dos access time

2003-06-16 Thread Mark G
> Hi,

HerrO

> does not seem to update the last accessed time of c:\test
thats because by doing " > open(FILE,">c:\\test\\file.txt"); " you are
creating a new file. You should change that to
 "> open(FILE,">> c:\\test\\file.txt");". run this;

<~~~cut
#!PERL -w


open(FILE,'>> ./test.dat') || die "$!\n";
print FILE "hello";
close FILE;

print "last modified:\t" . scalar (localtime ( (stat "./test.dat")[8] ) );

<~~paste

hth,
Mark G
- Original Message - 
From: "Andrew Watson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 16, 2003 2:20 AM
Subject: updating dos access time



>
> In Win32 how do I make the dos access time , that obtained via 'dir
> /TW', reflective of when I add a file to a directory.
>
> For instance
>
> running
>
> open(FILE,">c:\\test\\file.txt");
> print FILE "hello";
> close FILE;
>
> does not seem to update the last accessed time of c:\test
>
> Thanks
> Andrew
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: I need to make this not end

2003-06-14 Thread Mark G
>all right, the only problem with the script you sent is that if it is = then the 
>number is always 10, its you asign "le" or < then it is >always 0.

>here is what you sent.  At least it works though.. I will keep working with it, and 
>thank you

Not sure what exactly you mean by that. If you mean that it only works with a static 
number Well do you want me to finish the script for you...or do you want to learn 
something ??  look down if you want it with a random number















<~~~ Cut

$im_thinking_of=int(rand 10);
while(){

  print "Pick a number:";
$guess=;
chomp $guess;
 if ($guess>$im_thinking_of) {
 print "You guessed too high!\n";
  } elsif ($guess < $im_thinking_of) {
  print "You guessed too low!\n";
  } else {
  print "You got it right!\n";
   last;
   }

}



<~~~ paste

  - Original Message - 
  From: Mr.T Mr.X 
  To: Mark G 
  Sent: Sunday, June 15, 2003 2:40 AM
  Subject: Re: I need to make this not end


  all right, the only problem with the script you sent is that if it is = then the 
number is always 10, its you asign "le" or < then it is always 0.

  here is what you sent.  At least it works though.. I will keep working with it, and 
thank you





  while(){
  $im_thinking_of=10;
print "Pick a number:";
  $guess=;
  chomp $guess;
   if ($guess>$im_thinking_of) {
   print "You guessed too high!\n";
} elsif ($guess < $im_thinking_of) {
print "You guessed too low!\n";
} else {
print "You got it right!\n";
last;
 }

  }




--
  Do you Yahoo!?
  SBC Yahoo! DSL - Now only $29.95 per month! 


Re: I need to make this not end

2003-06-14 Thread Mark G
>  I'm trying to make that ^^^  not end if you guess the number wrong.  The
chapter im reading is using the "for" and "while" >loop, but i guess I dont
know enough yet to do this.  Can someone help?

you would need some type of a look to itterate through your code, that is
why you book uses "for" and "while" {well actually you dont with an ugly
'goto' }. Here is one way to write your code with a while and perl's "last"
function:

<~~~ cut
while(){
$im_thinking_of=10;
  print "Pick a number:";
$guess=;
chomp $guess;
 if ($guess>$im_thinking_of) {
 print "You guessed too high!\n";
  } elsif ($guess < $im_thinking_of) {
  print "You guessed too low!\n";
  } else {
  print "You got it right!\n";
  last;
   }

}

<~~~paste
- Original Message - 
From: "Mr.T Mr.X" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 15, 2003 1:17 AM
Subject: I need to make this not end


> #!/user/bin/perl -w
>
> $im_thinking_of=int(rand 10);
>   print "Pick a number:";
> $guess=;
> chomp $guess;
>  if ($guess>$im_thinking_of) {
>  print "You guessed too high!\n";
>   } elsif ($guess < $im_thinking_of) {
>   print "You guessed too low!\n";
>   } else {
>   print "You got it right!\n";
> }
>
>  I'm trying to make that ^^^  not end if you guess the number wrong.  The
chapter im reading is using the "for" and "while" loop, but i guess I dont
know enough yet to do this.  Can someone help?
>
>
> -
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
>



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



Re: File not getting written

2003-06-12 Thread Mark G
- Original Message - 
From: "Jenda Krynicky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 12, 2003 9:17 AM
Subject: RE: File not getting written


> From: Rob Das <[EMAIL PROTECTED]>
> > I'm trying to merge a whole bunch of files (possibly tens of
> > thousands) into one file. Here's my code (with the error checking
> > removed for readability):
> >
> > opendir(INDIR, $indir);
> > @logfile=grep(/$mask/i, readdir INDIR);
> > closedir(INDIR);
> > [EMAIL PROTECTED]; # number of files matching mask
> > open(OUTFILE, ">$outdir$outfile");
> > for ( $ctr=0; $ctr<$nbrfiles; $ctr++ ) {
> > open(INFILE, "$indir$logfile[$ctr]");
> > print OUTFILE ;
> > close(INFILE);
> > }
> > close(OUTFILE);
>
> As I said before, read the file in chunks, 16KB chunks should be
> fine:

And while at it you should also probebly write out in chunks like this:

>
>  opendir(INDIR, $indir);
>  my @logfile=grep(/$mask/i, readdir INDIR);
>  closedir(INDIR);
>  my [EMAIL PROTECTED]; # number of files matching mask
>  my $buffer='';
>  open(OUTFILE, ">$outdir$outfile");
>  for ( $ctr=0; $ctr<$nbrfiles; $ctr++ ) {
>  open(INFILE, "$indir$logfile[$ctr]");
>  while (read INFILE, $buffer, 16*1024) {
syswrite OUTFILE, $buffer, 16*1024;
You should ofcourse check exactly how much you really read and thats how
much you'll have to write
>  }
>  close(INFILE);
>  }
>  close(OUTFILE);
>
> Jenda
> = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: very beginner

2003-06-11 Thread Mark G

Here is an example that i posted some time ago, :

<~~ cut
use Socket;
use Fcntl;
use POSIX;
my $PORT=2100;
my $proto=getprotobyname('tcp');



socket($socket,AF_INET,SOCK_STREAM,$proto) || die "couldn't get socket:
$!\n";


bind($socket,sockaddr_in($PORT,INADDR_ANY)) || die "couldn't bind: $!\n";;
listen($socket,5) || die "couldn't listen: $!\n";;


print "connected to: " .inet_ntoa( (sockaddr_in(
accept($remote_socket,$socket)

))[1] );

<~~~ paste

- Original Message - 
From: "Kipp, James" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 11, 2003 3:50 PM
Subject: RE: very beginner


> > > 
> > > Could someone direct me to the correct module to use for 
> > monitoring an
> > > Internet connection?  I just want to see the IP addresses 
> > of the machines
> > > trying to get into my PC.
> > 
> > Get a progam like Ethereal: http://www.ethereal.com/
> 
> or:
> netstat
> tcpdump 
> lsof 
> 
> and roll your own with Socket or IO::Socket. 
> 
> 
>  
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: typing files quickly

2003-06-10 Thread Mark G
hmm this misterious { _ } operand ?!? Is it sometype of a bitflag in the
stat code it self, perhaps some magical referance to return structure.
Anyhow here is a bit of code that utilizes it, run it in a directory with
about 10 files,

HTH, Mark

<~~~ CuT

use Benchmark::Timer;
use Fcntl ':mode';

$with_='for(0...1){foreach (glob "*"){print "$_ => Text\n" if -f ;print
"$_ => Directory\n" if -d _;print "$_ => Charachter\n" if -c _;}}';
$without_='for(0...1){foreach (glob "*"){print "$_ => Text\n" if -f
;print "$_ => Directory\n" if -d ;print "$_ => Charachter\n" if -c ;}}';

$t = Benchmark::Timer->new(slip => 1);

eval $with_;

# using _ with file tests
$t->start('1 times using _');
eval $with_;
$t->stop('1 times using _');
$t->report;


# using stat on each test
$t->start('1 times using stand');
eval $without_;
$t->stop('1 times using stand');
$t->report;

<~~ Paste
- Original Message - 
From: "Rob Dixon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 12:34 PM
Subject: Re: typing files quickly


> Harry Putnam wrote:
> > Steve Grazzini <[EMAIL PROTECTED]> writes:
> >
> > > Harry Putnam <[EMAIL PROTECTED]> wrote:
> > > > "Janek Schleicher" <[EMAIL PROTECTED]> writes:
> > > > >
> > > > > The underscore _ holds the results of the last stat call
> > > > > (implicitly called by the -f operator), so no unnecessary
> > > > > work needs to be done.
> > > >
> > > > I've seen that `_' crop up before
> > > > I don't understand what this means.
> > >
> > > It's documented in perlfunc:
> >
> > Yes, I saw it there too.  I must be having a particularly dense time
> > of it, but I still am missing what is actually in _
>
> There is nothing 'in' the underscore. What happens is that if
> you use the -X operators with '_' as the parameter, then instead
> of calling 'stat' to fetch the file's details the results of the
> last call to 'stat' are used directly. Where and how these are
> saved you don't need to know.
>
> > > $ perldoc -f stat
> > > [ snip ]
> > >
> > > If stat is passed the special filehandle
> > > consisting of an underline, no stat is done, but
> > > the current contents of the stat structure from
> >
> > The previous content of the stat structure is what? (in plain english)
> > Does it mean the previous values of the 13 elements produced by stat?
>
> Roughly. But the 13 elements are values that are set up to be handed
> back neatly to the Perl calling code. The information may be kept in this
> format or some other, but it doesn't matter to you.
>
> > Or something else...
> >
> >  if (-e $file and -f _) { ...
> >
> > What is -f being tested against.  If not $file then what...
>
> This is a particularly bad example, because -f will return
> 'true' only if the file actually exists anyway. But what
> this does is
>
>   - call stat($file)
>   - use the results to see if the file exists
>   - use the results to see if it's a regular file
>   - 'and' the two together and execute the conditional code accordingly
>
> > The
> >  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
> >$atime,$mtime,$ctime,$blksize,$blocks)
> > Resulting from the -e test?
>
> Sort of. But this is the list returned from 'stat' to
> Perl calling code. For -X operators 'stat' is called
> implicitly and has to remember only enough information
> to be able to derive that list, or the result of any
> subsequent '-X _' call.
>
> > Or getting back to original question...
> > perl -e '$mode = (stat($ARGV[0]))[2];print "$mode\n";' test.f
> > 33204
> >
> > What is it about 33204 that tells us `type' is a regular file
> > The first digit being 3?
>
> No.The fact that (33204 & S_IFMT) == S_IFREG
>
> >  perl -e '$mode = (stat($ARGV[0]))[2];print "$mode\n";' test.d
> > 16893
> >   "ditto  regular directory"
> > The first digit being 1?
>
> No. The fact that (16893 & S_IFMT) == S_IFDIR
>
> > That is, might one just look for a static part of $mode to know the
> > type?
>
> Yes. $mode & S_IFMT
>
> > perldoc -f stat seems to indicate it might?
> >
> > [...]
> > 0 dev  device number of filesystem
> > 1 ino  inode number
> > 2 mode file mode  (type and permissions)
> > [...]
> >
> > And a few tests with this:
> > #!/usr/local/bin/perl -w
> >
> > for(@ARGV){
> >chomp;
> >   $mode = (lstat($_))[2];
> >   if ( $mode =~ /^3/){
> > print  "$mode $_: Regular file\n";
> >   }elsif($mode =~ /^1/){
> > print "$mode $_: Directory\n";
> >   }elsif($mode =~ /^41/){
> > print "$mode $_: Symlink\n";
> >   }
> > }
> >
> > Seem to indicate it will work.
>
> No. I wrote the code to derive the file type from an 'lstat'
> call in a previous post and thought you were happy with that.
> Exactly how the filing system does it is something to trust
> and forget about. Especially from within Perl, which will
> happily that the bits are somewhere that aren't for the sake
> of portability.
>
> Rob
>
>
>
>
> -- 
> To unsubscribe

Re: Displaying Connections Or sessions to a Web site on NT/2000 Mach ines

2003-06-09 Thread Mark G
> Checking the sessions on the machine only shows users
> opening files

hmm, I bin loking for a module that can tell me what process has a file
opened on win box. what are you using ??

Mark G.

- Original Message - 
From: "Federico, Chris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 1:31 PM
Subject: Displaying Connections Or sessions to a Web site on NT/2000 Mach
ines


> Hi Group :),
>
>
>  Does anyone know of a module or how to display users connected to the Web
> process of an NT/2000 Server in Perl . Checking the sessions on the
machine
> only shows users opening files and not connected the the WWW process .
This
> would come in real handy ..
>
> Can anyone steer me in the right direction .
>
>
>
>
> Thanks
> Chris Federico
> Systems Engineer (AITS)
> Reuters
> 88 Parkway Drive South
> Hauppauge, NY 11788
> Office :631-233-6647
> Visit the ITS I-Web site for IT information or to log a support call at:
> <http://www.ime.reuters.com/itservices
> <http://www.ime.reuters.com/itservices> >
>
>
> -
> Visit our Internet site at http://www.reuters.com
>
> Get closer to the financial markets with Reuters Messaging - for more
> information and to register, visit http://www.reuters.com/messaging
>
> Any views expressed in this message are those of  the  individual
> sender,  except  where  the sender specifically states them to be
> the views of Reuters Ltd.
>
>



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



Re: Is empty directory?

2003-06-05 Thread Mark G

- Original Message - 
From: "Jair Santos" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 05, 2003 7:00 PM
Subject: Is empty directory?


> Hi all,
> 
> does anybody knows how to check if a diretory is empty?

 You can open it {opendir } and see for your self {readdir}

Mark G


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



Re: Unzip using perll

2003-05-31 Thread Mark G
- Original Message - 
From: "Manish Uskaikar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 31, 2003 12:34 AM
Subject: Unzip using perll


> Hi,
>
> I would like to find out, if there is any command which can do a unzip of
a *.zip file; This unzip should be of the form extract to specific folder.
>
> Thanking you in anticipation.
>
> Regards
> Manish U
>
http://search.cpan.org/author/NEDKONZ/Archive-Zip-1.05/lib/Archive/Zip/FAQ.pod



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



Re: MIME::Lite only sends 8k?

2003-05-31 Thread Mark G
Hi Michael,

> I have a report that is in HTML format, it is about 120k of text.  When
> is use the program fragment below to send the report, I get only the
> first 8k (about) and that's it.
>

judging by your code, you want to attach an HTML file as attachment (  Type
=>'multipart/related',
 ) , and only 8 K are geting over.

> The problem is the mail command can't format the message as html when it's
read.

Mail client is ASCII based you can however use a different editor { man
mail }.

Here is my script that does what you wanted and sends the whole file over
{ atleast on my box }:


<~~~ CUT

use MIME::Lite;
use Net::SMTP;
$smtp = Net::SMTP ->new('yourmail.server);
$smtp->mail('[EMAIL PROTECTED]');
$smtp->to('[EMAIL PROTECTED]);
$smtp->data( );


my $msg = MIME::Lite->new(
 From =>'Joe',
 To   =>'Shmoe',
 Subject  =>'HTML Test',
 Type=>'multipart/related',
 );

 $msg->attach(
   Type=> 'text/plain',
   Data => 'HERE IS YOUR HTML PAGE',
);



 $msg->attach(
   Type=> 'text/html',
   Path   =>'full_file_name',
   Disposition => 'attachment',
  );



# send the message over
$smtp->datasend( $msg->as_string() );


# close smtp connection
$smtp->dataend();
$smtp->quit;

<~~~ paste


- Original Message - 
From: "Michael Weber" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 30, 2003 4:18 PM
Subject: MIME::Lite only sends 8k?


> I have a report that is in HTML format, it is about 120k of text.  When
> is use the program fragment below to send the report, I get only the
> first 8k (about) and that's it.
>
> I ran into this same problem with MFMail, but it runs fine with the
> mail command (sendmail).  The problem is the mail command can't format
> the message as html when it's read.  What I see is the html source code.
>  The program below gets the formatting right, but it only sends the
> first small piece of the file.
>
> What am I doing wrong?
>
> I'm running RH 7.3 and perl 5.8.0.
>
> Thanx!
>
> #!/usr/bin/perl -w
>
> use strict;
> use MIME::Lite;
>
> my $msg = MIME::Lite->new(
>  From =>'[EMAIL PROTECTED]',
>  To   =>'[EMAIL PROTECTED]',
>  Subject  =>'HTML Test',
>  Type=>'multipart/related',
>  Data =>"Here's another test."
>  );
>
> $msg->attach(
> Type=> 'text/html',
> Path
> =>'/usr/local/results/111.222.333.444/report.html'
> );
>
> $msg->send;
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Can someone find out what's wrong ?

2003-05-31 Thread Mark G
Just out of curiosity what kind of cards are you using that you can change
the MAC address ??

Mark
- Original Message - 
From: "Nikolay Hristakiev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 30, 2003 12:36 AM
Subject: Can someone find out what's wrong ?


> I've got a script who looks for change of a MAC-address on
> LAN cards of my clients and put it in a fail if there is a
> change.
> Firts I made static ARP table in /etc/ehters it looks like this
> -
> mac address hostname
> mac address hostname
> -
> Afer this make arp -s -f
> and this is the script
> ##
> #!/usr/bin/perl
>
> # catching the info for the MAC addresses
> $ipmc = `/sbin/arp -n | grep ether`;
>
> @ipmc = split("\n", $ipmc);
>
> foreach $str (@ipmc) {
>   s/\t/ /g;
>   @strng = split("  ", $str);
>   $ip_mac{$strng[0]} = $strng[2];
> }
> # Read the file withe the static MAC addresses
> $ipmc = `cat  /etc/ethers`;
> @ipmc = split("\n", $ipmc);
> foreach $str (@ipmc) {
>   ($mac_def, $ip_def) = split("\t", $str);
>   $ip_fix{$ip_def} = $mac_def;
>   $ipfixip{$mac_def} = $ip_def;
> }
> # Check if there is a difference withe the static ones
> # and the real MAC addresses
> $set_err = 0;
> foreach $ip (sort keys %ip_mac) {
>   if ($ip_mac{$ip} ne $ip_fix{$ip}) {
>   $ip_lamer{$ip} = $ip_mac{$ip};
>   $set_err = 1;
>   }
> }
> # Put it in a fail
> if ($set_err ne 0) {
>   $dttoday = `date`;
>   chop($dttoday);
>   open (BADUSER,  ">>/var/httpd/html/private/badusers");
>   foreach $ip (sort keys %ip_lamer) {
>   $madmac = $ip_fix{$ip};
>   print (BADUSER
> "$dttoday\t$ipfixip{$madmac}\t$ip_lamer{$ip}\t$ip\n");
>   print  "Defined lame user.\n $dttoday\nFrom:
> $ipfixip{$madmac}\nMAC:$ip_lamer{$ip}\nTo: $ip\n";
>   }
>   close BADUSER;
> }
> 
> That is it.
> Sorry 4 my broken english
> For me seems everything to be Ok but it's not working :<
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: Comparing Dates Conditional statements

2003-05-27 Thread Mark G
> That won't work if the dates are more than a year apart(i.e. >100302 will

Thanx Tim, I didnt think about that. Perhaps you will need to break up the
string into 3 fields.

Mark G
- Original Message - 
From: "Tim Johnson" <[EMAIL PROTECTED]>
To: "'Mark G'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: "perl" <[EMAIL PROTECTED]>
Sent: Tuesday, May 27, 2003 5:10 PM
Subject: RE: Comparing Dates Conditional statements


>
> That won't work if the dates are more than a year apart(i.e. 100302 will
> appear to be greater than 011503).  I would recommend looking into the
> Time::Local module.  You can use it to convert the text dates into Perl
> time() format.  Then you can easily do a numeric conversion.
>
> -Original Message-
> From: Mark G [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 27, 2003 2:04 PM
> To: [EMAIL PROTECTED]
> Cc: perl
> Subject: Re: Comparing Dates Conditional statements
>
>
> > How can I have condition as such
> >
> > $date = 'XX/XX/XX'; <-insert any date
> > If $date is greater then 01/01/02 then do .
> > Else 
> >
>
> here is one simple way:
>
> <~~~cut
>
> $foo="01/01/02";
> $bar="01/03/02";
>
> $foo =~ s/\///g;
> $bar =~ s/\///g;
>
>
> if( $foo > $bar ){
>
>  print "\$foo is greater then \$bar \n";
>
> }
> elsif( $foo == $bar){
>
>  print "\$foo is equal to \$bar \n";
>
> }
> else {
>
>  print "\$bar is greater then \$foo \n";
>
> }
>
> <~~paste
> - Original Message - 
> From: "Paul Kraus" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, May 27, 2003 3:43 PM
> Subject: Comparing Dates Conditional statements
>
>
> > How can I have condition as such
> >
> > $date = 'XX/XX/XX'; <-insert any date
> > If $date is greater then 01/01/02 then do .
> > Else 
> >
> >
> > Paul
> >
> >
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: Comparing Dates Conditional statements

2003-05-27 Thread Mark G
> How can I have condition as such
> 
> $date = 'XX/XX/XX'; <-insert any date
> If $date is greater then 01/01/02 then do .
> Else 
> 

here is one simple way:

<~~~cut

$foo="01/01/02";
$bar="01/03/02";

$foo =~ s/\///g;
$bar =~ s/\///g;


if( $foo > $bar ){

 print "\$foo is greater then \$bar \n";

}
elsif( $foo == $bar){

 print "\$foo is equal to \$bar \n"; 

}
else {
 
 print "\$bar is greater then \$foo \n";

}

<~~paste
- Original Message - 
From: "Paul Kraus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 27, 2003 3:43 PM
Subject: Comparing Dates Conditional statements


> How can I have condition as such
> 
> $date = 'XX/XX/XX'; <-insert any date
> If $date is greater then 01/01/02 then do .
> Else 
> 
> 
> Paul
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: Threads blocking on solaris

2003-04-02 Thread Mark G
I dont know if this is the problem, but why do you issue a system
sleepperl has a built it sleep [perldoc -f sleep]. Is perl system thread
safe on Solaris ?? Maybe you launch your threads and they are sleeping and
you dont realize it , just my 2 cents.

Mark
- Original Message -
From: "Phil Schaechter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 02, 2003 6:27 PM
Subject: Threads blocking on solaris


> Hi all,
>
> I have a very interesting problem.  I have my main program waiting for
data on
> stdin, while other threads are running - and lauching yet more threads.
>
> Threads block while trying to launch new threads until I hit enter. The
code
> below (which I whipped out quickly to demo the problem) blocks until enter
is
> hit on solaris, but runs fine on linux.
>
> Does anyone have any clues for me?
>
> Perl version I run on solaris: This is perl, v5.8.0 built for
> sun4-solaris-thread-multi
>
> Perl version I run on linux: This is perl, v5.8.0 built for
> i686-linux-thread-multi
>
> The code:
>
> #!/usr/bin/perl
> use threads;
> use threads::shared;
>
> my $key, @cmds, $new_thread;
>
> print "> ";
> while ( chop($key = ) )
>   {
>   @cmds = split(/ /, $key);
>
>   if ( $cmds[0] eq "run" )
>   {
>   $new_thread = new threads \&monitor
>   }
>
> print "> ";
>   }
>
> sub monitor
>   {
>   my $self_thread = threads->self();
>   my $self_id  = $self_thread->tid();
>
>   while (1)
>  {
>  system("sleep 15");
>  print "calling load_stream_starter...\n";
>  load_stream_starter(5);
>  print "Load stream starter finished\n";
>  }
>   }
>
> sub load_stream_starter
>   {
>   my $to_start = shift;
>   my $i, $new_thread, $new_id;
>
>
>  for( $i = 0; $i < $to_start; $i++)
> {
> print "Preparing to launch...";
> $new_thread = new threads \&run_func;
> $new_id = $new_thread->tid();
> print "launched $new_id\n";
> }
>   }
>
>
> sub run_func
>   {
>
>   while (1)
> {
> system("sleep 5");
> print "I'm running\n";
> }
>   }
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



dup2 on XP

2003-03-31 Thread Mark G
Hello guys,

I think that perl 5.8 on winXP has a problem with file descripter tables. It fails to 
properly handle parents STDOUT when I dup2 in the child. Here is my script that runs 
fine on my FreeBSD box. It properly redirects childs STDOUT to a file , while leaving 
parents STDOUT to the screen. On an XP box, it redirects both parents and childs 
STDOUT to a file. Any ideas on how to work around it ??

_cut script__



#!/usr/bin/perl -w

# $? child error
# $$ pid


use POSIX qw ( :sys_wait_h :unistd_h);
use IO::Handle;


my $CHILD_SPAWNED=0;
my $CHILD_TO_CREATE=5;
my $MAX_CHILD=3;
my $CHILD_CREATED=0;
$|=1;



#open a file for childs redirection
open(FD,"> ./output") || myerrno();




while( $CHILD_SPAWNED < $CHILD_TO_CREATE ){

print  "---\t\t RUNING $CHILD_CREATED\n";

if( $CHILD_CREATED < $MAX_CHILD ){
 

 die "couldnt not spawn: $!" unless defined ( my $PID=fork() );

 $CHILD_CREATED++; 
 $CHILD_SPAWNED++;


 unless( $PID ){
  $|=1;
  dup2(fileno(FD) , fileno(STDOUT) ) || myerrno();
  close(FD);
  $^F=3; #make the redirection get past exec
  print "I am child $$...about to exec\n";

 { exec ("perl count.pl") }; print STDERR "could not exec: $!";
 
 }


}


$status=waitpid(-1,WNOHANG);

if( $status != 0 ){ #some child has exited
 $CHILD_CREATED--;

 print "child $status has exited \n";
}




}


print  "TOTAL CHILD SPAWNED IS $CHILD_SPAWNED\n";


sub myerrno{
 foreach $Val (keys( %!) ){
  print "$Val $!{$Val}\n" if $!{$Val}; 
 
 }
exit(1);
}


paste script_


dup2 and IPC

2003-03-27 Thread Mark G
hi all,

I am having a problem with duping stdout and socket. When my client forks of children, 
the childrens stdout is then duped with a socket. Which is what I want, but for some 
reason the parents stdout gets redirected as well. I want the parents STDOUT to stay 
the same and only redirect childs stdout. Am I missing something or forgeting 
something ?? 

thanx,
Mark


_paste server_

use Socket qw(:DEFAULT :crlf);
use IO::Handle;
use Fcntl;
use POSIX;

my $PORT = 2100;
$|=1;

#get socket and make it reusuable,set it to raw sock 
socket($SOCKET,AF_INET,SOCK_DGRAM,scalar getprotobyname('udp') ) || myerrno();

$my_addr=sockaddr_in($PORT,INADDR_ANY);
bind($SOCKET,$my_addr);

$SOCKET->blocking(0);
$SOCKET->autoflush(1);


 
print "server up ad ready for connections\n";
# start recieving the data

while(){

 $remote_addr=recv($SOCKET,$buff,"1000",0) or die "problem with recv: $!";

 $msg_recived++;

 ($R_port,$R_addr)=sockaddr_in($remote_addr);
   $R_addr=inet_ntoa($R_addr);

 print "\nrecived:\n $buff\n...from $R_addr:$R_port MSG number $msg_recived\n";
}

sub myerrno{
 foreach $Val (keys( %!) ){
  print "$Val $!{$Val}\n" if $!{$Val}; 
 
 }
exit(1);
}

_paste server_



_cut client___

use POSIX qw ( :sys_wait_h :unistd_h);
use Socket qw(:DEFAULT :crlf);
use IO::Handle;
use Fcntl;



my $CHILD_SPAWNED=0;
my $CHILD_TO_CREATE=10;
my $MAX_CHILD=3;
my $PORT = 2100;
my $CHILD_CREATED=0;
$|=1;





while( $CHILD_SPAWNED < $CHILD_TO_CREATE ){

# lets get the socket readY


#get socket  
socket($SOCKET_OUT,AF_INET,SOCK_DGRAM,scalar getprotobyname('udp') ) || myerrno();

# make it non-buffred non-block IO
$SOCKET_OUT->blocking(0);
$SOCKET_OUT->autoflush(1);

 
# pack the destination address with port
$f_addr=sockaddr_in($PORT,inet_aton("127.0.0.1") );

# set the destination address on socket
connect($SOCKET_OUT,$f_addr) || myerrno();




if( $CHILD_CREATED < $MAX_CHILD ){

 die "couldnt not spawn: $!" unless defined ( my $PID=fork() );

 $CHILD_CREATED++; 
 $CHILD_SPAWNED++;

 unless( $PID ){

$status=dup2(fileno($SOCKET_OUT),fileno(STDOUT) );
print $SOCKET_OUT "hello from $$\n";


 exit(0);
 }


}


 close $SOCKET_OUT;

$status=waitpid(-1,WNOHANG);

if( $status != 0 ){ #some child has exited
 $CHILD_CREATED--;

 print "child $status has exited \n";
}




}


syswrite(\*STDOUT, "TOTAL CHILD SPAWNED IS $CHILD_SPAWNED\n");

sub myerrno{
 foreach $Val (keys( %!) ){
  print "$Val $!{$Val}\n" if $!{$Val}; 
 
 }
exit(1);
}

paste client


Re: Socket Problem

2003-03-24 Thread Mark G
Hello Stefan,

> Ok, I replied to the previous response to my post and it apparently didn't
> go through, but it's irrelevant anyway.  (My response to the "why bother"
> was summed up with "so I can learn how it's done.")
>

good point, although why not build the socket your self [ you can even pack
raw sockets if you wish ]??


> When I do the sockets this way, it waits for input on the $dccsocket
> without
> moving on to work on the information from the $socket until I send a /dcc
> close
> chat $mybotsnick... After I close the DCC CHAT connection, it reads from
> the $socket again without problem...  I've change this recently to:
>
in the snipet you send there is no code to handle "/dcc close" . The
behavior you explained fallows as your code. I think the only reason you are
geting past the read , is because $dccsocket points to a non valid handle.
If you have warnings enabled you should get a message.

 >With the
> $socket->blocking(0) and the sysread() calls, I should be able
> to read without problems from either one, but now it fails to even open
the
> $dccsocket.

ok before I answare that, dont mix blocking IO with NON_blocking IO[ print
on socket, stdio and all high level io functions use there own buffering
scheme ] atleast $|=1 on top of your script should disable stdlib buffering,
I woudl avoid print and <> in general for NON-BLOCKING IO.

> print $socket "PRIVMSG $channel $dcctmp\r";
 are you sure all data got send over this socket ?? maybe the server has
closed your socket by now ?? or maybe it couldnt handle the whole message ??
If I was you I would select() to make sure socket is ready for read. check
sysread if it return anything  or $! might be EWOULDBLOCK.

$data="PRIVMSG $channel $dcctmp\r";
$status=sysread($socket,$data,$max_buff);
if( defined $status){
if($status >0){print "full read of $status bytes on socket" if
$debug); }
else{ print "recieved EOF on socket\n" if $debug; }
}
elsif($! == EWOULDBLOCK){warn "socket no read to be read yet\r\r";#handle
how you wish }
else{ warn "error on socket: $!"; }



> bypass the router and neither one works.  The second may be due to
> the way XChat opens it's socket.  If it bound it to listen on a
> specific IP then it may not be listening to localhost and I wouldn't be
> able to connect, but the only IP it should listen on
> if that's the case is my '192.168.x.x' IP from my router.  I
> tried setting to that IP as well with no luck

could be, if you want send me your IP and i'll give it a run.

Mark

- Original Message -
From: "Stefan Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Mark G" <[EMAIL PROTECTED]>
Sent: Monday, March 24, 2003 12:32 PM
Subject: Re: Socket Problem


> On Sun, 23 Mar 2003 22:43:16 -0500, Mark G <[EMAIL PROTECTED]> wrote:
>
> > Hi Stefan,
> >
> > If you have two different sockets open, one should not block the other
no
> > meter what kind of a socket that is. Send some of the code, might help
us
> > help you.
> >
> > Mark
>
> Ok, I replied to the previous response to my post and it apparently didn't
> go through, but it's irrelevant anyway.  (My response to the "why bother"
> was summed up with "so I can learn how it's done.")
>
> I added that for the benefit of the list. :)
>
> Now... the following is a snippet of the relevant code (before I changed
> it to use non-blocking IO.)
>
> - Cut Below --
>
> #!/usr/bin/perl
>
> $server = 'localhost';
> $port = 6667;
>
> $channel = '#mychannel';
>
> $a = (special character for dcc, actions, etc...)
>
> $dccexists = 0;
> $dcctmp = "";
>
> $socket = IO::Socket::INET->new(
>Proto => 'tcp',
>PeerAddr => $server,
>PeerPort => $port
> );
>
> unless( $socket ) {
>die( "Could not connect to $server:$port" );
> }
>
> $socket->autoflush(1);
>
> while ( $tmp = <$socket> ) {
>if { $tmp ne "" ) {
>   if ( $dccexists == 1 ) {
>  $dcctmp = <$dccsocket>;
>   }
>   if ( $dcctmp ne "" ) {
>  print "PRIVMSG $channel $dcctmp\n";
>  print $socket "PRIVMSG $channel $dcctmp\r";
>  $dcctmp = "";
>   }
>   @tmps = split( /:/, $tmp );
>   $command = $tmps[2];
>   @tmps = split( ' ', $tmp );
>   if ( $command =~ /DCC CHAT/i ) {
>  $command =~ s/$a//g;
>  $dccport = $tmps[$#tmps];
>  

Re: counting fork process, again

2003-03-24 Thread Mark G
Hi Chad,

I think your error lay in the place where Jenda pointed for you. Going posix
way is the right way if you intend to do a lot of low level stuff your self.

Mark
- Original Message -
From: "chad kellerman" <[EMAIL PROTECTED]>
To: "beginners" <[EMAIL PROTECTED]>
Sent: Monday, March 24, 2003 1:58 PM
Subject: counting fork process, again


>
> Helloe everyone,
>I was wondering is someone can help me out with an issue with forking.
I
> am trying to fork 8 process at a time.
>
>Here is what I have:
>
> 
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use lib ".";
> use BACKUP;   #my own module
> use POSIX ":sys_wait_h";
>
> my( $MAX_CHILDREN ) = "8";
> my( $CHILD_PIDS ) = "0";
> my( $maxtries ) = "7";
> my( $failure ) = "0";
>
> # there are actually 100 hostIds. but you should get the point..
> my( @hostIds ) = "10.10.10.1, 10.10.10.2, 10.10.10.3 ,10.10.10.4";
>
> $SIG{CHLD} = \&CHILD_COUNT($CHILD_PIDS);
>
> FORK:
> {
>
> HOSTID: foreach my $hostId ( @hostIds ) {
>
> redo HOSTID if $CHILD_PIDS >= $MAX_CHILDREN;
>
>   if( my $pid = fork ) {
> $CHILD_PIDS++; #Add the children up until we hit the max
> next;
> }elsif (defined $pid) {
> #  In here I do some stuff with each $hostID.
> # To make the code easier to read, I made a module
that
> # has a bunch of subroutines in it.
> #There are basically 2 subroutines that I call for
each
> # hostID.  1 grabs the quota for each user on the
hostId,
> #The other tars and copies the user where the script
> # is.  I eval my connection and if some fails I
> # go on to the next. ex.
>  until ( (BACKUP->QuotaIt( $hostId ) or ( $failures ==
> $maxtries ) ) ) {
>   $failures++;
>   if ( $failures == $maxtries ) {
>  my( $subject ) = "Hey, WTF is up with
$hosId";
>  my( $message ) = "$0 failed to connect to $hostID.";
>  BACKUP->MailIt( $subject, $message, $daily );
>  #go to the next hostid
>  next HOSTID2;
>  } #if statememt
>  } #until statement
>
>}elsif($! =~ /No more process/){
> sleep 15;
>   redo; #do over.
> }else{
> # this is just a mail routine that mails be that I
> #can't fork
> my( $subject ) = "Failed to fork any children";
> my( $message ) = "$0 failed to fork anymore children.
> BACKUP->MailIt( $subject, $message, $daily );
> die;
> }
>
> } # foreach loop ends
>
> } # this is the FORK
>
>
> sub CHILD_COUNT {
> my $child_pids = @_;
> my $child = waitpid(-1,WNOHANG);
> while ($child != -1 && ($child_pids > 0 )) {
> $child_pids--;
> $child = waitpid(-1,WNOHANG);
> }
> }
>
> 
>
>Just typing this I realized that if I can't fork then I probably won't
be
> able to mail myself a notification.  So I gotta change that else statement
> with the mail notification.
>
>Anyways,  the issues I am having are two fold. The first I get this
> warning:
>Not a subroutine reference at ./script.pl line  331 which is:
>  " redo HOSTID2 if $CHILD_PIDS >= $MAX_CHILDREN;"
>
>   The second is a bigger issue.  I also fork in the "home made" perl
module
> for each user of the HostId I am doing.
> nothing crazy, just.
>
> #--#
> foreach $user (@users) {
> my( $pid ) = fork ();
> die "Cannot fork: $!" unless defined( $pid );
> if ( $pid == 0 ) {
> #do tarring of user
> exit 0;
> }
> waitpid($pid,0);
> }
> #---#
>
> Here I get the error:
> Not a subroutine reference at BACKUP.pm line 195.
> which is: " waitpid($pid,0);"
>
>   I know this is very confusing.  And I might not even be posting to the
right
> list.  But I am so frustrated with trying to get this thing to work.  It
> seems as if I have searched everywhere for examples of limiting the number
of
> forked processes, then being able to fork with in a fork.
> I originally was using Parallel::ForkManager.   But I found that if I
set
> the max_processes to 8 it will start eight but will not contiue until all
> eight were done, then only do one at a time.
>
>   That's when I decided to go the POSIX route and use fork..  But just
can't
> get it working.  I think setting the SIG{CHLD} is messing things up.  BUt
I
> am not sure.
>
>   Sorry for being so drawn out.  Please feel free to tear me/my code up.
I am
> new and would really like to know how to do this.  Don't worry I can take
> criticism pretty well... lol
>
> Thanks in advance,
>
> Chad
>
>
>
>
>
> --
> To unsubscribe, e-mail: [EMA

Re: Socket Problem

2003-03-23 Thread Mark G
Hi Stefan,

If you have two different sockets open, one should not block the other no
meter what kind of a socket that is. Send some of the code, might help us
help you.

Mark

- Original Message -
From: "Stefan Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 22, 2003 10:24 AM
Subject: Socket Problem


> Hi,
> I've googled for this information and not found much.
> Probably just haven't found the right combination of
> keywords.  I have a project I'm doing to learn about
> IRC better.  I'm writing a bot in perl (without using
> the Net::IRC or POE modules) and I can connect to the
> server, join the channel I want to join, and pass
> commands to the bot via the channel and direct
> messages.  What I'm running into trouble with is DCC.
> I want to be able to DCC chat with it and have it
> repeat what I tell it via DCC into the chat room.
> I have a socket set up at the beginning for
> connecting to the IRC server.  This is the main
> socket, but I have to open a second socket for DCC,
> so I set one up if and only if the bot receives a
> DCC request from $controller (me).  The problem is
> that I can open this second socket, but then it's
> the only socket I can communicate with until I send
> a "/dcc close chat $botnick" in the channel, THEN
> it repeats only the last thing it heard from the
> $dccsocket.  I think this is due to blocking calls
> on the sockets I'm working with, but when I tried
> setting it to fcntl( $socket, O_NONBLOCKING ) (or
> at least I think that's what I did, it's been a
> while) it goes through the loop once then quits
> instead of looping until it receives input.  Has
> anyone tried this before?  Or done some other
> project that required both read and write access
> on 2 open sockets without that project being a server?
> I found an example of using select() but it appears
> to only work on server sockets.  I need something
> that works with client sockets.  I'm using this
> module for my sockets... IO::Socket.  I'm also
> using perl 5.6.1 on cygwin on WinXP Home.  I prefer
> NOT to use Net::IRC nor POE as I'm doing this project
> mostly as a learning experience and I feel I wouldn't
> be learning anything to resort to someone else's work.
> (and the only reason I'm using IO::Socket is that I've
> worked with normal sockets enough to know I can do it
> already.)  If anyone needs to see the code for the
> sockets, please let me know.  I'll post what I'm doing
> if it's necessary.
>
> Thank you for your time,
> Stefan
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Getting keyboard scancode, etc.

2003-03-23 Thread Mark G
Hi Beau,

Dont know much about linux, but over on BSD there is a /dev/console . I am
sure you can play with that, there are also open source key-loggers from
which you can probebly extract the info you are looking for. Let me know how
it go's.

Mark

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "ktb" <[EMAIL PROTECTED]>
Sent: Sunday, March 23, 2003 10:43 AM
Subject: Re: Getting keyboard scancode, etc.


> On 23 Mar 2003 at 9:32, ktb wrote:
>
> > On Sun, Mar 23, 2003 at 04:14:58AM -1000, [EMAIL PROTECTED] wrote:
> > > Hi Everyone -
> > >
> > > I remember using the DOS keyboard software interrupt
> > > in the old, old days to get the scancode, shift/alt/
> > > ctrl state, the ascii code, etc. from a keystroke.
> > > I need this information for a cross-os application
> > > I am trying to write.
> > > [...]
> > > How do I get them in Linux running under X? I've
> > > looked and looked in CPAN and nothing rings
> > > a bell...
> > >
> > > Aloha => Beau;
> >
> > If you just want the scan-code -
> > $ man -k key
> >
> > dumpkeys
> > xmodmap
> >
> > hth,
> > kent
>
> Thanks kent, but what I want to do is wait (or poll,
> or get a key event) on the keyboard and when a key
> is pressed (I guess actually on 'key up') obtain
> the scancode and control key state at that time.
> I am now looking through the X man pages - but I
> still can't find any ready-to-go perl module...
>
> Aloha => Beau;
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Help! Telnet-->FTP

2003-03-21 Thread Mark G
you can also write your own telnet client that can establish FTP sessions on
the fly. In perl it would be simple, I wrote a pritty nice FTP server in
about a day or so.

Mark

- Original Message -
From: "Jeff Westman" <[EMAIL PROTECTED]>
To: "beginners" <[EMAIL PROTECTED]>
Sent: Friday, March 21, 2003 3:56 PM
Subject: RE: Help! Telnet-->FTP


> Seems such a shame to have to call perl from the command line or (last
> resort), run FTP using the shell.
>
> Your explanation makes sense.  What a pain!
>
>
> --- [EMAIL PROTECTED] wrote:
> >
> > 
> > On Fri, 21 Mar 2003 12:29:06 -0800 (PST), Jeff Westman
<[EMAIL PROTECTED]>
> > wrote:
> >
> > > I need help!
> > >
> > > I am connecting to a remote server using Net::Telnet.  I am then
running
> > some
> > > programs, which works fine.  Now I need to send the results back to
the
> > local
> > > server that established the connection.
> > >
> > > #- start
> > > $t = new Net::Telnet (Input_Log  => "__debug_log" );
> > > ...
> > > print "Attempting FTP from $store to $local\n";
> > > @result = $t->cmd( $ftp = Net::FTP->new($local)  );
> > > #- end
> > >
> > > When this completes, it executes the following on the remote server:
> > >
> > >   $ Net::FTP=GLOB(0x4027a304)
> > >   ksh: syntax error: `(' unexpected
> > >   $
> > >
> > > Maybe I am doing this wrong, but I am attempting to create an ftp
object
> > in
> > > the middle of a telnet call.
> > >
> >
> > Ah the "beauty" of a client/server environment.  The parameter you pass
to
> > the 'cmd' of the Telnet object is a program (command line) to run in the
> > shell of the external connection. So you are telling it to run the
command
> > Net::FTP=GLOB, etc. which is not a command. So to FTP from the remote
> > location either you have to call an ftp client on the remote location on
> > the command line, or you could do something really hokey like calling
perl
> > with the -e operator and passing all of your code over to the perl as a
one
> > liner, this naturally requires Perl to be installed on the remote
location.
> > Essentially all of this is VERY ugly and a pain in the butt, but it can
be
> > done. In fact we are doing this over an SSH connection, but it ain't
pretty
> > let me tell ya (and I didn't write it).
> >
> > http://danconia.org
> >
>
>
> __
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> http://platinum.yahoo.com
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Fork ?

2003-03-19 Thread Mark G
Ok I wrote you a quick example jeroe. I only had time to test it on a Xp
box, this should work on *nix as well since most of my coding is on *nix.
What you are looking for is a set of exec and waitpid call's to do the trick
for you. Basicly this is how its usually don with forking.

a: parents forks
b: child exec's
c: parent keeps track of childs

You might wanna expiriment with threads. It would not only give you beter
control, more flexibility, but also faster perforamce.

-->>> CUT

use POSIX ":sys_wait_h";
my $CHILD_SPAWNED=0;
my $CHILD_TO_CREATE=20;
my $MAX_CHILD=3;
$|=1;

while( $CHILD_SPAWNED < $CHILD_TO_CREATE ){

print "---\t\t RUNING $CHILD_CREATED\n";

if( $CHILD_CREATED < $MAX_CHILD ){

 die "couldnt not spawn: $!" unless defined ( my $PID=fork() );

 $CHILD_CREATED++;
 $CHILD_SPAWNED++;

 unless( $PID ){
 $|=1;

 print "I am child $$...about to exec\n";

 { exec ('c:\perl\count.pl') }; print STDERR "could not exec: $!";

 }


}

# child never get's here

$status=waitpid(-1,WNOHANG);

if( $status != 0 ){ #some child has exited
 $CHILD_CREATED--;

 print "child $status has exited \n";
}

}


print "TOTAL CHILD SPAWNED IS $CHILD_SPAWNED\n";


<- PASTE


-> CUT

#c:\perl\count.pl
while($i<10){$i++};
print $i;

<<<-- PASTE




- Original Message -
From: "Jeroen Lodewijks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 19, 2003 3:03 PM
Subject: Fork ?


> Hi all,
>
> Not sure if this appropriate for the beginners list but there is no
> intermediate list :)
>
> I am writing a program in Perl to 'move' output from one process.
> The program looks in a database which contains lists of files.
>
> These files are either FTP'ed to mailed to recipients.
>
> I actually made this program using modules Mime::Lite and Net::FTP
> No sweat really.
>
> But when I FTP or mail, the program waits, so I want to make it multi
> process.
> And there is my problem. I tried fork() but it doesn't do what I want or I
> got it wrong.
> (maybe it's not the appropriate thing to use anyway)
>
> So my question is: how to start multi processing?
>
> Just imagine I have 'datapump', I gathered all data required to send it.
> What I want now is that a separate process is started to send the file
> (either by FTP or mail).
> The data pump continues and spawns up to 10 processes, if more it will
wait.
>
> Here is what I thought would work: (try program)
>
> #!/bin/env perl
>
> use strict;
>
> my $ADD = 0;
> my $WAIT = 1;
>
> {
> my $state = $ADD;
> my $processes = 1;
>
> sub ProcessHandler
> {
> my $request = @_;
>
> print "REQUEST = $request STATE = $state PRC =
> $processes\n";
>
> if ($state == $ADD) {
> my $pid = fork();
> die "Cannot fork: $!" unless defined($pid);
> if ($pid == 0) {
>   # Child process
> $processes++;
> if ($state > 10) {
> $state = $WAIT;
> }
> sleep (int(rand 20) + 1);
> print "child proc added PRC = $processes\n";
> }
> else {
> print "MAIN process PRC $processes\n";
> }
> }
> elsif ($state == $WAIT) {
> print "WAIT\n";
> wait;
> $state = $ADD;
> $processes--;
> print "child proc removed PRC = $processes\n";
> }
> }
> }
>
> my $i;
> for ($i = 0;; $i < 20; $i++) {
> print "HI! $i\n";
> ProcessHandler($i);
> };
>
>
> It doesn't do what I want at all. It spawns way too many processes.
> (and I get errors in win 2000).
>
> Basically, I want to spawn a process which does something (call a
> subroutine)
> The main process should just continue pumping data which is spawned up to
10
> processes.
> Else it should wait until 1 of the 10 processes finishes.
>
> Any code examples out there??
>
> PS The target machine is a Unix box.
>
> Thanx,
>
> Jeroen
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: Script does not want to run, error

2003-03-05 Thread Mark G
Make sure your script starts with
#!/path/to/perl

then change permission of the script,
chmod 755 file_to_set

try to run your script, if it doesnt work try

#perl file_to_run

Mark
- Original Message -
From: "mel awaisi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 05, 2003 5:11 PM
Subject: Script does not want to run, error


> Hi,
>
> I am having problems opening this script on my machine. i have been
getting
> help from a very helpful person on this list.
>
> I have checked the shebang line, that perl exists, and perl -v gives
proper
> output.
>
> i try to run the script below as follow:
>
> [EMAIL PROTECTED] httpd]# cd cgi-bin
> [EMAIL PROTECTED] cgi-bin]# ls -la
> total 28
> drwxr-xr-x2 me   root 4096 Mar  5 21:49 .
> drwxr-xr-x5 me   root 4096 Mar  3 01:50 ..
> -rwxr-xr-x1 me   root  268 Mar  4 13:50 printenv
> -rwxr-xr-x1 me   me   1792 Mar  5 15:20 renamer
> -rwxr-xr-x1 me   me   1788 Mar  4 16:40 renamer.cgi
> -rw---1 root root 1731 Mar  5 21:49 renamer.pl
> -rwxr-xr-x1 me   root  757 Mar  3 01:50 test-cgi
> [EMAIL PROTECTED] cgi-bin]# renamer.pl &
> [1] 10254
> [EMAIL PROTECTED] cgi-bin]# bash: renamer.pl: command not found
>
> [1]+  Exit 127renamer.pl
> [EMAIL PROTECTED] cgi-bin]#
>
>
> [EMAIL PROTECTED] cgi-bin]# ./renamer.pl &
> [1] 10297
> [EMAIL PROTECTED] cgi-bin]# bash: ./renamer.pl: Permission denied
>
> [1]+  Exit 126./renamer.pl
> [EMAIL PROTECTED] cgi-bin]#
>
>
>
> Regards,
>
> Mel
>
>
>
>
> _
> Worried what your kids see online? Protect them better with MSN 8
>
http://join.msn.com/?page=features/parental&pgmarket=en-gb&XAPID=186&DI=1059
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Coprocessor while running perl 5.4 (dos version)

2003-02-21 Thread Mark G
> If memory serves me 
...looks like no leaks to me :O)
- Original Message - 
From: "Jenda Krynicky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 21, 2003 9:50 AM
Subject: Re: Coprocessor while running perl 5.4 (dos version)


> From: Mark G <[EMAIL PROTECTED]>
> > > This looks a lot like an ix86.  What generation, I don't know.  Lst
> > > time I
> > remember explicitly knowing that my box had a >math coprocessor, I was
> > running a 386.  I believe the Pentium chip pulled the functionality
> > back into the CPU. >
> > 
> > that must be exactly it. the x486 was same thing. You needed an extra
> > co-processor math chip. Some P machines still have room for them. It
> > woudl be hard to find which exact OP is trying to use that.
> 
> If memory serves me right there were two branches of 486.
> 486DX which did have the coprocessor and 486SX which did not.
> 
> I think the computer should give you some CPU related info when it 
> boots up.
> 
> Jenda
> = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed 
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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




Re: Coprocessor while running perl 5.4 (dos version)

2003-02-21 Thread Mark G
> This looks a lot like an ix86.  What generation, I don't know.  Lst time I
remember explicitly knowing that my box had a >math coprocessor, I was
running a 386.  I believe the Pentium chip pulled the functionality back
into the CPU.
>

that must be exactly it. the x486 was same thing. You needed an extra
co-processor math chip. Some P machines still have room for them. It woudl
be hard to find which exact OP is trying to use that.

Mark

- Original Message -
From: "R. Joseph Newton" <[EMAIL PROTECTED]>
To: "Jenda Krynicky" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, February 21, 2003 9:20 AM
Subject: Re: Coprocessor while running perl 5.4 (dos version)


> Jenda Krynicky wrote:
>
> > > Exiting due to signal SIGNOFP
> > > Coprocessor not available at eip=00019634
> > > eax=000c20a0 ebx=00081240 ecx=00081240 edx=000c20a0 esi=000c5018
> > > edi= ebp= esp=000c1d84 Program R:\PERL.EXE
> >
> > What are the CPUs of the machines that do this?
>
> This looks a lot like an ix86.  What generation, I don't know.  Lst time I
remember explicitly knowing that my box had a math coprocessor, I was
running a 386.  I believe the Pentium chip pulled the functionality back
into the CPU.
>
> I ouwld suspect that this is a problem with the basic machine, rather than
with Perl per-se.
>
> Joseph
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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




Re: creating a shell

2003-02-13 Thread Mark G
> a real basic tutorial or doc of some kind that explains how to 
> write a simple shell

here is a real simple psuedo shell;

while(){
read from stdin
parse it
do something with it depending on the string read
}

- Original Message - 
From: "ktb" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 13, 2003 12:28 AM
Subject: creating a shell


> I was wondering if anyone knows any recourses on how to write a
> unix/linux shell in perl?  I found the site for psh but I'm not 
> advanced enough to understand the code.  What I'm looking for is 
> a real basic tutorial or doc of some kind that explains how to 
> write a simple shell.  I know this is an exercise for some programming
> classes so there must be some documentation somewhere.  All I'm finding
> on the net is, "how to use shells."
> Thanks,
> kent
> 
> -- 
> To know the truth is to distort the Universe.
>   Alfred N. Whitehead (adaptation)
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



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