From: botp Date: 2007-11-28T17:31:34+09:00 Subject: Re: Accessing a file server with ruby On Nov 28, 2007 12:05 AM, Anthony wrote: > This seems like it should be a simple solution, but I don't know > enough Ruby to do it. I am using Ruby 1.8.4. What I want to do is > browse a directory on a different computer (server) than the one > running Ruby. I know I can use Dir to browse directories, but I can't > get it to find the other server where the files are stored. Any help > is greatly appreciated. this is just a simple example, C:\family\ruby>irb +---------------------------------------------------------+ | hello, botp :) | | this is the irb conf (find me at C:/family/ruby/.irbrc) | | happy irb/rubying. | | you can now enter ruby commands | | type "quit" anytime to exit irb.. | +---------------------------------------------------------+ system 'dir \\\\bgdc01\\c$\\download' Volume in drive \\bgdc01\c$ has no label. Volume Serial Number is 281F-1297 Directory of \\bgdc01\c$\download 11/27/2007 04:44 PM . 11/27/2007 04:44 PM .. 11/27/2007 03:37 PM 38,184 botp_sample_dmpi_security_log_2007_nov_27 .evt 11/24/2007 04:52 PM 26,112 fastthread-1.0-mswin32.gem 11/17/2007 02:43 PM 1,787,060 npp.4.5.Installer.exe 10/08/2007 11:02 AM 10,590,471 ruby-1.8.6-p111-i386-mswin32.zip 4 File(s) 12,441,827 bytes 2 Dir(s) 29,531,443,200 bytes free #=> true system 'echo test create file > \\\\bgdc01\\c$\\download\testing.txt' #=> true system 'dir \\\\bgdc01\\c$\\download' Volume in drive \\bgdc01\c$ has no label. Volume Serial Number is 281F-1297 Directory of \\bgdc01\c$\download 11/28/2007 04:06 PM . 11/28/2007 04:06 PM .. 11/27/2007 03:37 PM 38,184 botp_sample_dmpi_security_log_2007_nov_27 .evt 11/24/2007 04:52 PM 26,112 fastthread-1.0-mswin32.gem 11/17/2007 02:43 PM 1,787,060 npp.4.5.Installer.exe 10/08/2007 11:02 AM 10,590,471 ruby-1.8.6-p111-i386-mswin32.zip 11/28/2007 04:06 PM 19 testing.txt 5 File(s) 12,441,846 bytes 2 Dir(s) 29,531,377,664 bytes free #=> true system 'type \\\\bgdc01\\c$\\download\\testing.txt' test create file #=> true system 'dir \\\\bgdc01\\c$\\download\\testing.txt' Volume in drive \\bgdc01\c$ has no label. Volume Serial Number is 281F-1297 Directory of \\bgdc01\c$\download 11/28/2007 04:06 PM 19 testing.txt 1 File(s) 19 bytes 0 Dir(s) 29,531,115,520 bytes free #=> true system 'dir test.rb' Volume in drive C is hd Volume Serial Number is 7CD8-B514 Directory of C:\family\ruby 11/24/2007 01:06 PM 362 test.rb 1 File(s) 362 bytes 0 Dir(s) 2,659,557,376 bytes free #=> true require 'FileUtils' #=> true include FileUtils #=> Object cp 'test.rb', '\\\\bgdc01\\c$\\download\\' #=> nil system 'dir \\\\bgdc01\\c$\\download\\' Volume in drive \\bgdc01\c$ has no label. Volume Serial Number is 281F-1297 Directory of \\bgdc01\c$\download 11/28/2007 04:23 PM . 11/28/2007 04:23 PM .. 11/27/2007 03:37 PM 38,184 botp_sample_dmpi_security_log_2007_nov_27 .evt 11/24/2007 04:52 PM 26,112 fastthread-1.0-mswin32.gem 11/17/2007 02:43 PM 1,787,060 npp.4.5.Installer.exe 10/08/2007 11:02 AM 10,590,471 ruby-1.8.6-p111-i386-mswin32.zip 11/28/2007 04:23 PM 362 test.rb 11/28/2007 04:06 PM 19 testing.txt 6 File(s) 12,442,208 bytes 2 Dir(s) 29,530,783,744 bytes free #=> true note, i'm accessing thru an admin share (not commonly adviseable) kind regards -botp