FileSystemWatcher vs. Win32::ChangeNotify

2006-08-27 Thread Bullock, Howard A.
>From the Win32::ChangeNotify docs: the Win32 API which implements this
feature does not provide any indication of what triggered the
notification (as far as I know). If you're monitoring a directory for
file changes, and you need to know which file changed, you'll have to
find some other way of determining that.

The FileSystemWatcher
(http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher.as
px) seems to be able to watch specific files. 

I would prefer to use the functionality of FileSystemWatcher. Can
someone give me some pointers as to how I can use this FileSystemWatcher
via Perl?

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::ChangeNotify - Modified File Name...

2005-10-03 Thread Keith.Watson
> 
> [EMAIL PROTECTED] wrote:
> > Bonjour,
> >
> >  I search for help with Win32::ChangeNotify, is there a way (and
a
> > example please) on how to know what was the file that have
changed?!?  I
> > found people talking about a module name: "AdvNotify" that can tell
me
> > that but I never been able to find the module!!!

If you can't get the module to work you might want to look into putting
a Perl wrapper around FileNotify.

http://www.xtware.com/filenotify/

keith

-- 

Keith R. WatsonGTRI/ISD
Systems Support Specialist III Georgia Tech Research Institute
[EMAIL PROTECTED]   Atlanta, GA  30332-0816
404-894-0836

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::ChangeNotify - Modified File Name...

2005-10-03 Thread Peter Guzis



To my 
knowledge, Win32::AdvNotify was only ever released as a binary PPM for 
ActivePerl 5.6.  The source code was never released, the module's web site 
no longer exists, and no one has heard from the author in years.  
That being said, if you need the functionality of Win32::AdvNotify and can 
resign yourself to using ActivePerl 5.6, you can still find this module at http://www.geocities.com/floydian_99/Win32-AdvNotify.tar.gz.  
If you want to stay current though, I second Bill's 
solution.

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of 
  [EMAIL PROTECTED]Sent: Monday, October 03, 2005 7:52 
  AMTo: perl-win32-users@listserv.ActiveState.comSubject: 
  Win32::ChangeNotify - Modified File Name...
  Bonjour,
   
   I search for help with 
  Win32::ChangeNotify, is there a way (and a example please) on how to know what 
  was the file that have changed?!?  I found people talking about a module 
  name: "AdvNotify" that can tell me that but I never been able to find the 
  module!!!
   
      
  Any help appreciated!
   
  
  Dub
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Win32::ChangeNotify - Modified File Name...

2005-10-03 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:
> Bonjour,
>  
>  I search for help with Win32::ChangeNotify, is there a way (and a
> example please) on how to know what was the file that have changed?!?  I
> found people talking about a module name: "AdvNotify" that can tell me
> that but I never been able to find the module!!!

I think you're going to have to read the directory before doing the
ChangeNotify and store the pertinent attributes of each file (depending
on what you decide to use for events.  Your best bet would probably
be a hash of arrays with the filename/path being the key and the value
the array of attributes (size, etc).  Then if you get an event you'll
need to re-read the dir and check each file against your hash to see
first if it exists and then if it does if the array info is different.
At the same time, you may want to create a sorted array of matches to see
if the list is shorter and a file was deleted - then compare that array
to a sort of the hash keys to see which file was deleted.

Sorry - no snippet to offer.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32::ChangeNotify - Modified File Name...

2005-10-03 Thread Dupuis.Dominic



Bonjour,
 
 I search for help with Win32::ChangeNotify, is 
there a way (and a example please) on how to know what was the file that have 
changed?!?  I found people talking about a module name: "AdvNotify" that 
can tell me that but I never been able to find the 
module!!!
 
    
Any help appreciated!
 

Dub
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: second try - Win32::ChangeNotify

2005-08-05 Thread Michael Meltzer
solved my problem ! found perl script dirmon.pl at dave roth's site.
Thanks again for your advice and to mention dave roth's site.

Michael


Ñåðãåé ×åðíèåíêî wrote:

> hello, Michael,
>
> Friday, August 05, 2005, 1:07:42 PM, You wrote:
>
> MM> If I start or stop the service I get the start or stop message by mail
> MM> but if I create or delete a file in the monitored directory I get no
> MM> message.
>
> MM> Why ?
>
> MM> Environment: Win2000 (upgrade from NT) SP4
> MM> ActiveState perl 5.6.1.623
> MM> Win32::ChangeNotify 1.02
>
> I think it's not Win32::ChangeNotify issue. most likely service
> not properly installed. And on Roth's site (roth.net) there is
> module Win32::Daemon which can be used to install service
> properly. hope this help You.
>
> MM> Michael
>
> --
> Ñ óâàæåíèåì,
>  Ñåðãåé   mailto:[EMAIL PROTECTED]
>
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

--
+-- Michael Meltzer -+-+
|   AED-SICAD Aktiengesellschaft |   EMail : [EMAIL PROTECTED]  |
|   Lilienthal-Str. 7|   Phone : +49-89-45026-108  |
|   85579 Neubiberg  |   Fax   : +49-89-45026-113  |
++-+




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: second try - Win32::ChangeNotify

2005-08-05 Thread Michael Meltzer
Thank you for your reply.
I tryed Win32::Daemon but i don't know how to pause Wait( Infinite ) ?

Michael

Ñåðãåé ×åðíèåíêî wrote:

> hello, Michael,
>
> Friday, August 05, 2005, 1:07:42 PM, You wrote:
>
> MM> If I start or stop the service I get the start or stop message by mail
> MM> but if I create or delete a file in the monitored directory I get no
> MM> message.
>
> MM> Why ?
>
> MM> Environment: Win2000 (upgrade from NT) SP4
> MM> ActiveState perl 5.6.1.623
> MM> Win32::ChangeNotify 1.02
>
> I think it's not Win32::ChangeNotify issue. most likely service
> not properly installed. And on Roth's site (roth.net) there is
> module Win32::Daemon which can be used to install service
> properly. hope this help You.
>
> MM> Michael
>
> --
> Ñ óâàæåíèåì,
>  Ñåðãåé   mailto:[EMAIL PROTECTED]
>
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

--
+-- Michael Meltzer -+-+
|   AED-SICAD Aktiengesellschaft |   EMail : [EMAIL PROTECTED]  |
|   Lilienthal-Str. 7|   Phone : +49-89-45026-108  |
|   85579 Neubiberg  |   Fax   : +49-89-45026-113  |
++-+




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: second try - Win32::ChangeNotify

2005-08-05 Thread Сергей Черниенко
hello, Michael,

Friday, August 05, 2005, 1:07:42 PM, You wrote:

MM> If I start or stop the service I get the start or stop message by mail
MM> but if I create or delete a file in the monitored directory I get no 
MM> message.

MM> Why ?

MM> Environment: Win2000 (upgrade from NT) SP4
MM> ActiveState perl 5.6.1.623
MM> Win32::ChangeNotify 1.02

I think it's not Win32::ChangeNotify issue. most likely service
not properly installed. And on Roth's site (roth.net) there is
module Win32::Daemon which can be used to install service
properly. hope this help You.

MM> Michael




-- 
С уважением,
 Сергейmailto:[EMAIL PROTECTED]


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


second try - Win32::ChangeNotify

2005-08-05 Thread Michael Meltzer
This message I posted yesterday but got now answer except some out of office 
replies.
Maybe my Question was not clear.
My Question is:
why does the script not fire if it runs as service ?



With this module I monitor changes in a directory:

&mailprot("Monitoring started");   

$WatchSubTree = 1;  
$Events = 'FILE_NAME';      

Win32::ChangeNotify::FindFirst($monitor, $MonDir, $WatchSubTree,
FILE_NOTIFY_CHANGE_FILE_NAME
  );

 while ($monitor->FindNext()) {
$monitor->Wait( INFINITE );
#sleep(300);
$Inhalt = "";   
if (! opendir (BKDIR, "$MonDir")) {   
  &mailprot("can't opendir $MonDir:\n   $!\n");
}
while (defined ($fname = readdir(BKDIR))) {
   next if $fname =~ /^\.$/;   
   next if $fname =~ /^\.\.$/;
   next if $fname =~ /@ReadMe\.htm/i;
   next if $fname =~ /^Bitte Version und Sprache/i;
   $Inhalt = "${Inhalt}\n$fname";  
}   
close BKDIR;
&mailprot("Aenderungen im Briefkasten:\n$Inhalt");
 }

END{ &mailprot("Monitoring stopped"); } 
exit 0;


I compiled the program with perl2exe to an exe file.

If I start the  program from comand line all works fine.
If it runs as service I get the start message (see first line in script) but no
message if something changes in the monitored directory.

The service was created as described in Dave Roth's  Book
'Win32 Perl Scripting', Page  274  in the following way:

instsrv.exe "Monitor"  C:\WIN_NT\system32/srvany.exe

Modifying the registry was not as described in the book. I had to create 
the Parameters key.
Should the key not be there already ?
That's what I now have in the registry:
'Monitor' has the keys Enum, Parameters, Security
Parameters has the String Values: Application   REG_SZ  Path to my exe file
  AppParameters REG_SZ
  (Default) REG_SZ  (Value not set)

If I start or stop the service I get the start or stop message by mail
but if I create or delete a file in the monitored directory I get no 
message.

Why ?

Environment: Win2000 (upgrade from NT) SP4
ActiveState perl 5.6.1.623
Win32::ChangeNotify 1.02

Michael

-- 
Michael Meltzer  AED-SICAD AGLilienthal-Str. 7  D-85579 Neubiberg
Tel.:+49 89 45026 108Fax: +49 89 45026 113
[EMAIL PROTECTED]
http://www.aed-sicad.de/

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32::ChangeNotify

2005-08-04 Thread Michael Meltzer

With this module I monitor  changes in a directory:

&mailprot("Monitoring gestartet");   

$WatchSubTree = 1;  
$Events = 'FILE_NAME';      


Win32::ChangeNotify::FindFirst($monitor, $MonDir, $WatchSubTree,
   FILE_NOTIFY_CHANGE_FILE_NAME
 );

while ($monitor->FindNext()) {
   $monitor->Wait( INFINITE );
#sleep(300);
   $Inhalt = "";   
   if (! opendir (BKDIR, "$MonDir")) {   
 &mailprot("can't opendir $MonDir:\n   $!\n");

   }
   while (defined ($fname = readdir(BKDIR))) {
  next if $fname =~ /^\.$/;   
  next if $fname =~ /^\.\.$/;

  next if $fname =~ /@ReadMe\.htm/i;
  next if $fname =~ /^Bitte Version und Sprache/i;
  $Inhalt = "${Inhalt}\n$fname";  
   }   
   close BKDIR;

   &mailprot("Aenderungen im Briefkasten:\n$Inhalt");
}

END{ &mailprot("Monitoring gestoppt"); } 
exit 0;



I compiled the program whith perl2exe to an exe file.

If I start the  program from comand line all works fine but if it runs 
as service I get no
message if something changes in the monitored directory but i get the 
start message

(see first line in script)

The service was created as described in Dave Roth's  Book
'Win32 Perl Scripting', Page  274  in the following way:

instsrv.exe "monitor"  C:\WIN_NT\system32/srvany.exe

Modifying the registry was not as described in the book. I had to create 
the Parameters key.

Should the key not be there already ?
That's what I now have in the registry:
'Monitor' has the keys Enum, Parameters, Security
Parameters has the String Values ApplicationREG_SZ  Path to my 
exe file

  AppParameters REG_SZ
  (Default)   
REG_SZ  (Value not set)

If I start or stop the service I get the start or stop message by mail
but if I create or delete a file in the monitored directory I get no 
message.

Why ?

Details: Win2000 (upgrade from NT) SP4
ActiveState perl 5.6.1.623
Win32::ChangeNotify 1.02

Michael

--
Michael Meltzer  AED-SICAD AGLilienthal-Str. 7  D-85579 Neubiberg
   Tel.:+49 89 45026 108Fax: +49 89 45026 113
[EMAIL PROTECTED]
http://www.aed-sicad.de/

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Win32::ChangeNotify

2001-11-21 Thread Bas Janssen

Hello Simon,

Thanks !!
It works well.
After I created the directory the function was executed and waited for any
chances in the directory.
After I deleted the directory and tried it again I got the same error as you
did.

( The stupid thing is I created the directory before, but on the wrong place
. :-)

Greetings

Bas Janssen
The Netherlands


- Original Message -
From: "Simon Oliver" <[EMAIL PROTECTED]>
To: "Bas Janssen" <[EMAIL PROTECTED]>; "Perl-Win32-Users (E-mail)"
<[EMAIL PROTECTED]>
Cc: "Christopher J. Madsen" <[EMAIL PROTECTED]>
Sent: Wednesday, November 21, 2001 12:26 PM
Subject: Re: Win32::ChangeNotify


> Just tried print $^E as well and got:
>
> "Error creating Win32::ChangeNotify object: The directory name is
> invalid at - line 11."
>
> So I went and created a directory 'c:\winnt\chdir' and it went well.
> What does $^E return for you?
>
> --
>   Simon Oliver
>
> use strict;
>
> require Win32::ChangeNotify;
>
> my $Path = "c:\\winnt\\chdir";
> my $WatchSubTree = 0;
> my $Events = "FILE_NAME";
>
> my $notify = Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);
>
> die "Error creating Win32::ChangeNotify object: $^E" unless ref $notify;
>
> $notify->reset;
> $notify->wait;
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Win32::ChangeNotify

2001-11-21 Thread Simon Oliver

Just tried print $^E as well and got:

"Error creating Win32::ChangeNotify object: The directory name is
invalid at - line 11."

So I went and created a directory 'c:\winnt\chdir' and it went well. 
What does $^E return for you?

--
  Simon Oliver

use strict;

require Win32::ChangeNotify;
 
my $Path = "c:\\winnt\\chdir";
my $WatchSubTree = 0;
my $Events = "FILE_NAME";
 
my $notify = Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);

die "Error creating Win32::ChangeNotify object: $^E" unless ref $notify;
  
$notify->reset;
$notify->wait;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Win32::ChangeNotify

2001-11-21 Thread Simon Oliver

Slightly modified script confrms that Win32::ChangeNotify is not
returning an object:

use strict;

require Win32::ChangeNotify;
 
my $Path = "c:\\winnt\\chdir";
my $WatchSubTree = 0;
my $Events = "FILE_NAME";
 
my $notify = Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);

die "Error creating Win32::ChangeNotify object" unless ref $notify;
  
$notify->reset;
$notify->wait;


I even tried this (after looking at ChangeNotify.pm) to no avail.

use strict;

use Win32::ChangeNotify qw(FILE_NOTIFY_CHANGE_FILE_NAME);
 
my $Path = "c:\\winnt\\chdir";
my $WatchSubTree = 0;
my $Events = FILE_NOTIFY_CHANGE_FILE_NAME;
 
my $notify = Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);

die "Error creating Win32::ChangeNotify object" unless ref $notify;
  
$notify->reset;
$notify->wait;

Looks like somehting is broken.

--
  Simon Oliver
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Win32::ChangeNotify

2001-11-21 Thread Bas Janssen



Hello,
 
When I try the following ; 
 
require Win32::ChangeNotify;
 
$Path = "c:\\winnt\\chdir";$WatchSubTree = 
"0";$Events = "FILE_NAME";
 
$notify=Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);$notify->reset;$notify->wait;
 
I get the following error : 
Can't call method "reset" on an undefined value at 
p.pl line 10.
 And the same with the wait 
function.
 
What am I doing wrong ?
 
Thanks
 
Bas


RE: Win32::ChangeNotify not working on NT

2001-02-02 Thread Rogers, John

HI,

try useing

my $path =  'C:\Timothymarsch\SHARE'; 

instead of,  

my $path =  "C:Timothymarsch\\SHARE";

 is \\

I dont know if there are different versions, or if it matters but mine says
the variable name is $WatchSubTree
not $subtree
eg.
        $notify = Win32::ChangeNotify->new($Path,$WatchSubTree,$Events);

john

> -Original Message-
> From: David Prowak [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, 30 January 2001 5:07
> To:   [EMAIL PROTECTED]
> Subject:  Win32::ChangeNotify not working on NT
> 
> Hi,
> I have a simple program using Win32::ChangeNotify that
> works on my Win98 machine but does not work on the
> same
> machine when booted as a Win NT Server.
> 
> The error message indicates a problem with the $path.
> If I change the $path to "C:" under Win NT, it runs,
> but acts "funny".  By "funny" I mean that it does not
> stop the monitoring when I place a file in "C:".
> (No error message is displayed, is just says
> "monitorDir.pl die on line 14".)
> Meanwhile, once again, on a Win98 machine, everything
> works.  Help!!!  What the heck is wrong?
> 
>  use strict;
>  use Win32::ChangeNotify;
> # Look for any changes in the watched Dir.  
> # Changes include renames, deletions and creations.
>  my $filter = "FILE_NAME";  
> 
>  my ($notify);    
>  my $path =  "C:Timothymarsch\\SHARE";
>  
>  my $subTree = 1;  
>  my $retValue;# return value
> 
>  $notify = Win32::ChangeNotify->new($path, $subTree,
> $filter) || die $!;
>  $retValue = $notify -> wait or die "Something failed:
> $!\n";
> 
>  if ($retValue == 1) {
>  print "hip, hip horaay!\n";
>  } else {
>  print STDERR "$notify\n";
>  }
> 
> TIA,
> Dave
>  
> 
> 
> 
> 
> __
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices. 
> http://auctions.yahoo.com/
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
> 
## 
Disclaimer 

If this e-mail has been sent to you in error, please notify 
Océ-Australia Limited immediately and delete this e-mail from 
your system. 

Any views expressed in this e-mail are those of the individual 
sender and may not necessarily reflect the views of 
Océ-Australia Limited. 
##
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Win32::ChangeNotify not working on NT

2001-01-29 Thread David Prowak

Hi,
I have a simple program using Win32::ChangeNotify that
works on my Win98 machine but does not work on the
same
machine when booted as a Win NT Server.

The error message indicates a problem with the $path.
If I change the $path to "C:" under Win NT, it runs,
but acts "funny".  By "funny" I mean that it does not
stop the monitoring when I place a file in "C:".
(No error message is displayed, is just says
"monitorDir.pl die on line 14".)
Meanwhile, once again, on a Win98 machine, everything
works.  Help!!!  What the heck is wrong?

 use strict;
 use Win32::ChangeNotify;
# Look for any changes in the watched Dir.  
# Changes include renames, deletions and creations.
 my $filter = "FILE_NAME";  

 my ($notify);  
 my $path =  "C:Timothymarsch\\SHARE";
 
 my $subTree = 1;  
 my $retValue;  # return value

 $notify = Win32::ChangeNotify->new($path, $subTree,
$filter) || die $!;
 $retValue = $notify -> wait or die "Something failed:
$!\n";

 if ($retValue == 1) {
 print "hip, hip horaay!\n";
 } else {
 print STDERR "$notify\n";
 }

TIA,
Dave
 




__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Win32::ChangeNotify not working on NT

2001-01-29 Thread David Prowak

 
 

__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



System shutdown and Win32::ChangeNotify

2000-10-26 Thread Rogers, John

Howdy all,

I am using Changenotify with a "wait" in a script, that I then compile with
perl2exe -gui to make a background process. it all works just dandy, and
everybody's happy ! ...Until the system is shutdown,
when a program not responding type message is displayed. (tcl notifier, i.e.
the wait is waiting, if that sounds right.)

Is there anyway to detect that windows 95/98 is being shutdown.  so that I
can close the changenotify,
or die gracefully.

Have fun,
John Rogers
email [EMAIL PROTECTED] 







you cant sue us,


## 
Disclaimer 

If this e-mail has been sent to you in error, please notify 
Océ-Australia Limited immediately and delete this e-mail from 
your system. 

Any views expressed in this e-mail are those of the individual 
sender and may not necessarily reflect the views of 
Océ-Australia Limited. 
##
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Win32::ChangeNotify::wait_any?

2000-09-30 Thread Ed Moon

Well,

A stupid error on my part. I was never incrementing my array index ($i)
while building the array.

Anyways, I've run into a different problem.

While traversing the directory tree, the script dies attempting to create
the 48 entry in the array.

Does anyone know if there is a limit in the number of ChangeNotify objects
one can create?

I'm running Build 522 on Windows 2000 Professional with 384MB ram.

--- BEGIN SCRIPT ---
use strict;
use Win32::ChangeNotify;
use Win32::MAPI qw(Yes);
use File::Find; # module that handles recursively scanning dirs for us

# --- GLOBALS START ---
my ($filter) = "FILE_NAME|LAST_WRITE|SIZE"; # look for change in file name,
last modified time and file size
my $notify; # index for @dirs, indicates which object got triggered
my (@dirs) = []; # array of ChangeNotify objects
my (@names) = []; # array of dir names for reporting

my ($i) = 0; # index needed during population of arrays

# --- GLOBALS END ---

find ( \&finder, @ARGV); # recursively populate @dirs with ChangeNotify
objects for any dirs found

while (1) {
print STDERR "Watching...\n";
$notify = Win32::ChangeNotify::wait_any(@dirs) or die "Could not wait!:
$!";
$notify--; # decrement by one. changenotify returns 1 based index while
array are 0 based
print STDERR "$notify\n";
&message($notify);
$dirs[$notify]->reset() or die "Could not reset object $notify:$!"; #
reset the object
}

# --- subs ---

sub finder {
# used by File::Find to process files found in the directories
# this reads in the file looking for a line eq $look and then parses the
rest of the file

my ($file) = $_; # name of subdirectory or file
my ($path) = $File::Find::name; # get path with file/dir name

return if (-f $file); # skip files
$names[$i] = $path;
$dirs[$i] = Win32::ChangeNotify->new ($path, 1, $filter) or die "Failed
creating ChangeNotify object: $!";
$i++;
print STDERR "Registered $path\n";
}

sub message {
my($obj)=new Win32::MAPI(UseDefProfile=>Yes);
my %message = ();
my ($i) = shift;

$message{To} = ['[EMAIL PROTECTED]'];

$message{Subject} = "[Perlbot] Something changed on QAWEB1";

$message{Text} = "This is an automated message.\n The size, contents, or
last changed date of a file on server has changed in $names[$i]\n";

$obj->Send(\%message);
undef $obj;

}
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Ed
Moon
Sent: Friday, September 29, 2000 7:10 PM
To: '[EMAIL PROTECTED]'
Subject: Win32::ChangeNotify::wait_any?


I'm having problems with the following script run as 'notify.pl k:'

I want to monitor a mounted share and all sub directories for any file
changes. If I monitor just the root directory (with '$notify->wait or warn
"Something failed: $!\n";) it works.

But I want more granular notification and used the wait_any function.

If I copy a file into a monitored directory, wait_any never seems to
trigger.

Anyone know what I'm doing wrong?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Win32::ChangeNotify::wait_any?

2000-09-29 Thread Ed Moon

I'm having problems with the following script run as 'notify.pl k:'

I want to monitor a mounted share and all sub directories for any file
changes. If I monitor just the root directory (with '$notify->wait or warn
"Something failed: $!\n";) it works.

But I want more granular notification and used the wait_any function.

If I copy a file into a monitored directory, wait_any never seems to
trigger.

Anyone know what I'm doing wrong?

--- BEGIN SCRIPT ---
use strict;
use Win32::ChangeNotify;
use Win32::MAPI qw(Yes);
use File::Find; # module that handles recursively scanning dirs for us

# --- GLOBALS START ---
my ($filter) = "FILE_NAME|LAST_WRITE|SIZE"; # look for change in file name,
last modified time and file size
my $notify; # index for @dirs, indicates which object got triggered
my (@dirs) = []; # array of ChangeNotify objects
my (@names) = []; # array of dir names for reporting

my ($i) = 0; # index needed during population of arrays

# --- GLOBALS END ---

find ( \&finder, @ARGV); # recursively populate @dirs with ChangeNotify
objects for any dirs found

while (1) {
    print STDERR "Watching...\n";
$notify = Win32::ChangeNotify::wait_any(@dirs) or die "Could not wait!:
$!";
$notify--; # decrement by one. changenotify returns 1 based index while
array are 0 based
print STDERR "$notify\n";
&message($notify);
$dirs[$notify]->reset() or die "Could not reset object $notify:$!"; #
reset the object
}

# --- subs ---

sub finder {
# used by File::Find to process files found in the directories
# this reads in the file looking for a line eq $look and then parses the
rest of the file

my ($file) = $_; # name of subdirectory or file
my ($path) = $File::Find::name; # get path with file/dir name

return if (-f $file); # skip files
$names[$i] = $path;
$dirs[$i] = Win32::ChangeNotify->new ($path, 1, $filter) or die "Failed
creating ChangeNotify object: $!";
print STDERR "Registered $path\n";
}

sub message {
my($obj)=new Win32::MAPI(UseDefProfile=>Yes);
my %message = ();
my ($i) = shift;

$message{To} = ['[EMAIL PROTECTED]'];

$message{Subject} = "[Perlbot] Something changed on QAWEB1";

$message{Text} = "This is an automated message.\n The size, contents, or
last changed date of a file on server has changed in $names[$i]\n";

$obj->Send(\%message);
undef $obj;

}
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users