Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Win32 module for network neighborhood stuff

by japhy (Canon)
on Aug 22, 2001 at 02:41 UTC ( [id://106799] : perlquestion . print w/replies, xml ) Need Help??

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

I'm trying to access my Network Neighborhood (specifically, workgroups and the machines belonging to them) and I have no idea where to start. Can someone suggest a FAQ or a module to use?

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Win32 module for network neighborhood stuff
by Rudif (Hermit) on Aug 22, 2001 at 03:30 UTC
      Update: you can download scripts from the book from the publisher, Newriders.

      I tried to run several scripts and they seem to work as advertized.
      I can list domains, groups, machines, accounts, and more. To someone (me) who is not an admin, they look convincing.

      Rudif

Re: Win32 module for network neighborhood stuff
by thpfft (Chaplain) on Aug 22, 2001 at 04:34 UTC

    I'd suggest digging around the fringes of the Samba docs. There's a jolly but apparently authoritative guide to cifs, for example, which describes it as 'a recipe for protocol soup'.

    Other than that, not much. If you're running on linux there are a couple of modules that wrap around samba libraries. I haven't seen anything that does the same on windows, apart from some modules in the activestate distribution which are only really relevant to interactions with a domain controller (eg Win32::NetAdmin).

    Last resort: if you're on nt/2000 you can try reading the output of winfingerprint. or the source...

Re: Win32 module for network neighborhood stuff
by idnopheq (Chaplain) on Aug 22, 2001 at 18:47 UTC
    Best advice is to run over to http://www.activestate.com and check the archives and/or sign up for Perl-Win32-Admin mail list. Scripts like what you are looking for are constantly being asked for and posted there.

    Also, Dave Roth's site has gobs and gobs of info, and his books are great resources, too, as was mentioned.

    Here's a little Win32::OLE snippit from somewhere:

    #!/usr/bin/perl -w use strict; use Win32::OLE; use Win32::OLE::Enum qw(in); my $dom; $dom = Win32::OLE->GetObject ( "WinNT:" ); print "Domain\n\n----------------------------------------------------- +--------------------------\n"; foreach ( in $dom ) { print "$_->{Name}\n";}

    IMHO, the 'net' command was a great idea implemented horribly wrong by M$ and the raw, unadulterated POWER of perl is the best way to overcome this vast deficiency!

    HTH
    --
    idnopheq
    Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

Re: Win32 module for network neighborhood stuff
by japhy (Canon) on Aug 22, 2001 at 05:33 UTC
    I think I'll just interact with the net command...

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      Yuck. net command is nasty. Win32::NetAdmin does loads of what you want, maybe also Win32::NetResource if you are dealing with network shares etc - but for all the advanced stuff you'll need Win32::Lanman - not available on CPAN but a google search should reveal where it's hiding.

      If it's just a one off, net command is ok, I suppose!

      Error: Keyboard not attached. Press F1 to continue.