in reply to How do I search for a specific directory on a remote PC?

Once you've made the connection (to "\\$cpu\C$"), File::Find should work the same as if the directory were local to the machine the perl script is running on. Your wanted sub is responsible for accepting or rejecting any particular directory entry (file or dir).

Try running a UNIX find1 with various command line options until you get it to do exactly what you want, then run find2perl with those same options.

1 There are a number of available UNIX-ish command sets for Win/DOS. My favorite is U/WIN.

dmm

Replies are listed 'Best First'.
Re: Re: How do I search for a specific directory on a remote PC?
by Anonymous Monk on Jan 05, 2002 at 00:22 UTC
    File::Find works fine. I use it whenever I have a need to locate files. You just have to understand how to use the wanted function. It uses '/' instead of '\\' internally, but that's only an issue at display time. The following prints out directories it finds in a tree, starting in the current directory. You can easily modify it to act on files, store the names in a data structure, etc. Scoping issues are more quickly handled in the last example because you're not changing scope.
    use File::Find; find ( ref to function, start path(s) ) e.g.: use File::Find; find (\&wanted, '.'); sub wanted { print($File::Find::dir, "/$_\n") if -d $_; } or, just as good: use File::Find; find ( sub {print($File::Find::dir, "/$_\n") if -d $_}, '.');
    See perldoc File::Find for how to use $File::Find::dir and $_ in the wanted function.
      I decided my reply was incomplete, given the exact question you had. Here's some code that does it.
      use File::Find; use strict; our $belowpath = "common files"; our %found_dirs; find( \&foobar, 'c:/program files'); sub foobar { if ( $File::Find::dir =~ /$belowpath$/i && -d $_ ) { my $found = "$File::Find::dir/$_"; $found =~ tr/\//\\/; print "$found\n"; } }
      This prints:
      c:\program files\Common Files\Network Associates c:\program files\Common Files\Adobe c:\program files\Common Files\InstallShield c:\program files\Common Files\Symantec Shared c:\program files\Common Files\Services c:\program files\Common Files\System c:\program files\Common Files\ODBC c:\program files\Common Files\Microsoft Shared
Re: Re: How do I search for a specific directory on a remote PC?
by thunders (Priest) on Jan 05, 2002 at 00:00 UTC
    I have cygwin,it has a find program. That's the part in the docs that confused me, the wanted sub. Thanks for the tip.