http://www.perlmonks.org?node_id=117574


in reply to trouble with Win32::NetResource

jtarchie
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 }
cheers.
Ray