# Win 32 utils changenotify

**URL:** <https://www.ruby-forum.com/t/win-32-utils-changenotify/79440>\
**Category:** Ruby\
**Created:** [December 15, 2006, 3:55am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440 "2006-12-15T03:55:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 3:55am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/1 "2006-12-15T03:55:56Z")

</div>

I just downloaded and installed the win32utils installer. When I try to  
run the sample script provide in changenotify.txt

require “win32/changenotify”  
include Win32

# Wait for any writes to files in the C:\ drive.

filter = ChangeNotify::LAST\_WRITE  
cn = ChangeNotify.new(“C:\”,true,filter)  
cn.wait{ |s|  
puts “Something changed”  
puts "File: " + s.file\_name  
puts "Action: " + s.action

}

I get the following error.

:/ruby/lib/ruby/site\_ruby/1.8/i386-msvcrt/win32/ipc.so: invalid  
attribute name `recursive?' (NameError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from cjsample.rb:1

What am I doing wrong?

thanks,

Luis

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 4:51am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/2 "2006-12-15T04:51:59Z")

</div>

removed\_email\_address@domain.invalid wrote:

> puts “Something changed”  
> `require’  
> from cjsample.rb:1
> 
> What am I doing wrong?

You’ll need to upgrade to 0.4.2. You can either build from source or  
download the .so file directly, rename it to “changenotify.so”, and  
install it under c:\ruby\lib\ruby\1.8\i386-mswin32\win32.

The .zip file is at  
[http://rubyforge.org/frs/download.php/14978/win32-changenotify-0.4.2.zip](http://rubyforge.org/frs/download.php/14978/win32-changenotify-0.4.2.zip)  
The .so file is at  
[http://rubyforge.org/frs/download.php/14979/changenotify-0.4.2.so](http://rubyforge.org/frs/download.php/14979/changenotify-0.4.2.so)

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 5:22am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/3 "2006-12-15T05:22:01Z")

</div>

removed\_email\_address@domain.invalid wrote:

> > > cn = ChangeNotify.new(“C:\”,true,filter)  
> > > attribute name `recursive?’ (NameError)  
> > > [http://rubyforge.org/frs/download.php/14978/win32-changenotify-0.4.2.zip](http://rubyforge.org/frs/download.php/14978/win32-changenotify-0.4.2.zip)  
> > > The .so file is at  
> > > [http://rubyforge.org/frs/download.php/14979/changenotify-0.4.2.so](http://rubyforge.org/frs/download.php/14979/changenotify-0.4.2.so)
> > 
> > Regards,
> > 
> > Dan
> 
> I downloaded the file and renamed it according to your instructions but  
> I am still getting the same error.

Whoops. Download the latest win32-ipc and build from source or install  
the .so file in the same directory as before.

Source file:  
[http://rubyforge.org/frs/download.php/2757/win32-ipc-0.4.1.zip](http://rubyforge.org/frs/download.php/2757/win32-ipc-0.4.1.zip)

Shared object:  
[http://rubyforge.org/frs/download.php/4586/ipc.so](http://rubyforge.org/frs/download.php/4586/ipc.so)

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 5:06am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/4 "2006-12-15T05:06:01Z")

</div>

I downloaded the file and renamed it according to your instructions but  
I am still getting the same error.

Luis

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 5:52am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/5 "2006-12-15T05:52:03Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Thanks,
> 
> I acutally found out that I had 2 copies of changenotify.so in the ruby  
> folder. After deleting the older one it is working.
> 
> It works but it exits after a file change. Is it possible to  
> continuously monitor the folder?

Sure thing:

cn.wait{ |s|  
puts “Something changed”  
puts "File: " + s.file\_name  
puts "Action: " + s.action  
} while true

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 5:42am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/6 "2006-12-15T05:42:02Z")

</div>

Thanks,

I acutally found out that I had 2 copies of changenotify.so in the ruby  
folder. After deleting the older one it is working.

It works but it exits after a file change. Is it possible to  
continuously monitor the folder?

thanks

Luis

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 6:26am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/7 "2006-12-15T06:26:06Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Thanks for the help. I am still getting the following error when a file  
> event occurs.
> 
> Something changed  
> win32change.rb:11: undefined method `file_name' for #<Array:0x2cab5c8> (NoMethodError) from win32change.rb:9:in`wait’  
> from win32change.rb:9

Try this one:

cn.wait{ |arr|  
arr.each{ |info|  
p info.file\_name  
p info.action  
}  
} while true

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 6:22am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/8 "2006-12-15T06:22:05Z")

</div>

Thanks for the help. I am still getting the following error when a file  
event occurs.

Something changed  
win32change.rb:11: undefined method `file_name' for #<Array:0x2cab5c8> (NoMethodError) from win32change.rb:9:in`wait’  
from win32change.rb:9

Here’s the script I am using.

Luis

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 15, 2006, 9:14am UTC](https://www.ruby-forum.com/t/win-32-utils-changenotify/79440/9 "2006-12-15T09:14:16Z")

</div>

From Daniel B. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# Try this one:

# 

# cn.wait{ |arr|

# arr.each{ |info|

# p info.file\_name

# p info.action

# }

# } while true

# 

# Regards,

that works for me.  
btw, Daniel, would you know how to monitor file/dir changes in usbs? I  
have no idea yet since usbs are dynamic (now you see them, now you  
dont).

kind regards -botp

# Dan

# 

# 

#
