Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

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


Comment on Re: trouble with Win32::NetResource
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-29 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls