Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Identifying Windows file share names

by CaffeinatedCatatonic (Novice)
on Oct 29, 2018 at 18:38 UTC ( #1224872=perlquestion: print w/replies, xml ) Need Help??

CaffeinatedCatatonic has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monkers,

I have a number of Windows file servers (hundreds) to search for folders with specific characteristics. As the top level directories differ on each server I'm looking for a method where I can ask each server for it's top level share names. File::Find unfortunately doesn't walk the top of windows file shares. I'd like my input to be only a list of file servers and have my programs find everything from that. My servers are a mix of Windows versions and clients are also windows-based. Most clients are Windows 7 and up.

Thanks for your guidance in advance.

I wanted to thank Anonymous Monk for the Net View suggestion. We have hundreds of servers and workstations here with exported shares and most of these are not mounted on a drive letter. My intention here was to find a server and identify each share on the system and then walk that share with File::Find. File::Find works great except it fails to find the \\server\sharename at the root of the tree. Net View allowed me to quickly remedy my search. TIA.

Replies are listed 'Best First'.
Re: Identifying Windows file share names
by Discipulus (Abbot) on Oct 29, 2018 at 19:43 UTC
    Hello CaffeinatedCatatonic and welcome to the monastery and to the wonderful world of Perl!

    I doubt i understood your question: if so try to explain your needs in a more accurate way.

    From what I understand you connect to a server share, let's say \\10.10.10.10\share_name rigth? Now you want to know this share what path holds on the target server? Like c:\stuff\shared

    If my assumptions are correct you can wrap some perl code around wmic /node:10.10.10.10 share get name,path command.

    Like:

    my $remote = '10.10.10.10'; my $share = 'share_name'; # connect to the share.. ... # get info on the share from remote system open my $cmd, "wmic /node:$remote share get name,path|" or die; while (<$cmd>){ chomp; my ($got_name, $got_path) = split /\s+/, $_; if ($got_name eq $share){ print "share [$share] at $ip is remotely: $got_path\n" } }

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Identifying Windows file share names
by Lotus1 (Vicar) on Oct 29, 2018 at 19:30 UTC

    This thread discusses this topic how to list all the drive letters.

      does it?

        I probably should have asked the OP to specify if they wanted to get the drive letters for mapped drives. That's how I interpreted the phrase "top level directories". What is your assumption of what the OP meant?

Re: Identifying Windows file share names
by Anonymous Monk on Oct 29, 2018 at 22:06 UTC
    maybe
    use IPC::Run3 qw(run3); run3 ["NET","VIEW","\\\\servername","/all"], undef, \$stdout; die $? if $?; print "Output:\n$stdout\neof\n";
    untested
      I don't think that will get the volumes per se, just the named shares.
        volumes? show me where the OP said something about volumes. OP said

        I'm looking for a method where I can ask each server for it's top level share names.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1224872]
Approved by dorko
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2019-11-15 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (84 votes). Check out past polls.

    Notices?