Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: trouble with Win32::NetResource

by RayRay459 (Pilgrim)
on Oct 09, 2001 at 02:19 UTC ( #117574=note: print w/replies, xml ) Need Help??

in reply to trouble with Win32::NetResource

what version of perl are you running? How did you install the module. PPM is the best way to get modules installed. If you want a cludge way to do this, you could always do
open(NETVIEW, "net view|") or die "$!"; print NETVIEW;
Here's some code that i found while doing a search on netResource:
use Win32::Lanman; $odir = "C:\\TEMP\\SHARES"; if (!-e "$odir"){mkdir ($odir, 0777)|| die "Unable to create $odir";} %stype = (1,'Printer',-2147483648,'Default',0,'File', -2147483645, 'InterProcess Communication'); @servers = &getservers; foreach (@servers) { unless(Win32::Lanman::NetShareEnum("\\\\$_", \@shares)){next;} $output = ("$odir\\$_.txt"); open(OUTFILE, ">$output") || die ("cannot open output file ", $output +, "\n"); foreach $share (@shares) { print OUTFILE "Server = $_\n"; print OUTFILE "Name = ${$share}{'netname'}\n"; print OUTFILE "Type = $stype{${$share}{'type'}}"; $lc = chop ${$share}{'netname'}; if ($lc eq "\$"){print OUTFILE " (hidden)\n";}else{print OUTFILE "\n +"} print OUTFILE "Path = ${$share}{'path'}\n"; print OUTFILE "Remarks = ${$share}{'remark'}\n\n"; } close OUTFILE; } sub getservers { unless(my $domain = Win32::DomainName){print "Unable to obtain the do +main name.";} my ($PDC, $domain, @servers1, @S1, @S2); unless($domain = Win32::DomainName){print "Unable to obtain the domai +n name.";} foreach (SV_TYPE_DOMAIN_CTRL, SV_TYPE_DOMAIN_BAKCTRL, SV_TYPE_SERVER_ +NT) { unless(Win32::Lanman::NetServerEnum( '', $domain, $_, \@S1)){print " +Unable to obtain information on $_ .";} foreach (@S1){push( @S2, ${$_}{'name'})} push(@servers1, sort @S2); undef @S2; } undef ($domain, $PDC); undef @S1; return(@servers1); # Returns the server list }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117574]
and not a whimper to be heard...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-03-28 09:23 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (328 votes). Check out past polls.