Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just off the top of my head and having no idea how to get the windowdomain out of the output of nbtstat, what about:
use strict; open IP,"<IP.txt" or die "Couldn't open IP.txt, $!"; while(<IP>) { chomp; # does the while form of <> autochomp? I don't remember =[ my $out = `nbtstat -A $_`; if($out=~/WORKGROUP\s+<(\d+)>/) { my $domain = $1; #do something } }
My version of nbtstat, when run on myself, gave me this output:
C:\LiteStep>nbtstat -A Local Area Connection: Node IpAddress: [] Scope Id: [] NetBIOS Remote Machine Name Table Name Type Status --------------------------------------------- H4X0R-B0X <00> UNIQUE Registered WORKGROUP <00> GROUP Registered H4X0R-B0X <20> UNIQUE Registered MAC Address = 00-02-E3-14-A4-C5
I have no real idea what those numbers in the pointy brackets are, but I decided to capture them in my regex anyways. My version above just searches through the entire output for anything that matches the regex /WORKGROUP\s+<(\d+)>/ and then sets the $domain variable. However you could also easily do something like for(split/\n/,$out){ #operate on each line }.

In reply to Re: How can I get which Windows domain an IP belongs to? by BUU
in thread How can I get which Windows domain an IP belongs to? by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    NodeReaper snacks on some Soylent Green

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2018-03-22 01:00 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (272 votes). Check out past polls.