DOS Command help - the return

    First Previous
  • Mike_Hunt 24 May 2005 12:45:32 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    Ok, thanks to the folks who helped me out last time.

    It's time for level 2 now though, which is a bit harder. Here's what I've got:

    1 x 20meg file with a list of IP address

    Here's what I want:
    1 x file with a list of users/login names who uses those IP addresses

    Now I can get the information line by line by using the nbtstat -a command. This outputs the following:

    [code]
    nbtstat -A 111.111.111.111

    Name Type Status
    ---------------------------------------------
    H01111 UNIQUE Registered
    HO GROUP Registered
    H01111 UNIQUE Registered
    H01111 UNIQUE Registered
    U01111 UNIQUE Registered
    HO GROUP Registered

    MAC Address = 00-01-03-0D-FE-29
    [/code]

    The U01111 number is the username I'm after.

    However, this could be quite a lengthy process if I have to do this for each of the ips in this 20 meg file. I know it should be possible to write a basic batch file that does all of the work for me, but I'm struggling a little.

    Does anyone know of an easy way to take an IP out of the first file, run the nbtstat command on it, and output the U01111 (note - these won't always be U numbers, they could be pure text) number to another file, and repeat this process appending a the new user id each time it's run?

    Cheers for your help!

    [MH]
  • Tiger_Walts 24 May 2005 12:53:23 16,674 posts
    Seen 4 years ago
    Registered 19 years ago
    Doubt it can be done with batch file. You may have to get someone to write you an app.
  • Nuttah 24 May 2005 12:56:59 1,840 posts
    Seen 9 years ago
    Registered 18 years ago
    I concur, not a terribly hard app to write... (for a programmer).

    why cant this be done from the firewall? and why the hell are you looking at netbios connections?
  • Mike_Hunt 24 May 2005 12:57:58 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    The app option won't happen unfortunately.

    Can you recommend any sort of scripting language? I don't mind learning and it shouldn't be a complicated program, shirley?

    [MH]
  • ssuellid 24 May 2005 12:58:49 19,142 posts
    Seen 2 days ago
    Registered 20 years ago
    Perl. Download cygwin from somewhere and get Perl with it.
  • Mike_Hunt 24 May 2005 12:58:54 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    Nuttah wrote:
    I concur, not a terribly hard app to write... (for a programmer).

    why cant this be done from the firewall? and why the hell are you looking at netbios connections?
    Firewall doesn't log usernames, just IPs. That command is the only one I know that resolves the Username from IP.

    [MH]
  • Nuttah 24 May 2005 13:02:11 1,840 posts
    Seen 9 years ago
    Registered 18 years ago
    usernames... do you mean netbios names?

    frankly never used the command before. I'm just cant see why you would need to do this.
  • [maven] 24 May 2005 13:04:24 5,799 posts
    Seen 1 day ago
    Registered 17 years ago
    Mike_Hunt wrote:
    The app option won't happen unfortunately.

    Can you recommend any sort of scripting language? I don't mind learning and it shouldn't be a complicated program, shirley?

    [MH]

    Ruby.
  • Mike_Hunt 24 May 2005 13:12:45 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    Nuttah wrote:
    usernames... do you mean netbios names?

    frankly never used the command before. I'm just cant see why you would need to do this.
    What don't you understand?

    I need user names.

    I only have a list of IPs.

    That command gives me user names from IPs.

    That is why.

    [MH]
  • Nuttah 24 May 2005 13:49:03 1,840 posts
    Seen 9 years ago
    Registered 18 years ago
    Mike_Hunt wrote:
    What don't you understand?

    I need user names.

    I only have a list of IPs.

    That command gives me user names from IPs.

    That is why.

    [MH]

    There is absolutly no need to be so aggressive mike.

    nbtstat -A as far as I can see does not resolve "usernames" as you put it, it resolves remote machine names (i.e. the netbios name).

    and just to be pedantic, you havnt explained why, just what. If you do not wish to tell me, then just say.
  • DiscoMike 24 May 2005 13:51:11 570 posts
    Seen 7 hours ago
    Registered 17 years ago
    I think the point some others earlier were trying to make is that NBTSTAT does not return usernames.

    The NETBIOS name is returned. (computer name)
  • Deleted user 24 May 2005 13:59:35
    I was about to post a helpful reply until you turned into a tool mate.
  • tannerd 24 May 2005 14:05:35 2,691 posts
    Seen 1 month ago
    Registered 18 years ago
    NB take a copy of your IP Address file first...

    What you could do is open the file with a decent text editor (eg UltraEdit), do a find replace for the start of a line (or whatever you delimiter is) and insert "nbtstat -A "

    Then do a find/replace for the end of line and add " >> myfile.txt"

    Edit: can't remember if it is ">" or ">>" one will append, one will overwrite....
    Edit2: It is ">>", never mind.

    Rename the ip address file to ".bat" and run

    It won't give you just the usernames, so you'd have to parse out all the crap, but that should be straight forward.

    Give us an email if you want a hand...

    Edited by tannerd at 14:05:47 24-05-2005

    Edited by tannerd at 14:19:42 24-05-2005
  • tannerd 24 May 2005 14:14:28 2,691 posts
    Seen 1 month ago
    Registered 18 years ago
    DiscoMike wrote:
    I think the point some others earlier were trying to make is that NBTSTAT does not return usernames.

    The NETBIOS name is returned. (computer name)

    NBTSTAT -A displays the Remote Machine Name Table, one entry of which is the username.

    See www.microsoft.com/resources/documentation/Windows/2000
    /server/reskit/en-us/prork/pref_tts_pjtk.asp

    would link, but I keep getting EG errors
  • Mike_Hunt 24 May 2005 14:32:36 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    Nuttah wrote:
    There is absolutly no need to be so aggressive mike.

    nbtstat -A as far as I can see does not resolve "usernames" as you put it, it resolves remote machine names (i.e. the netbios name).

    and just to be pedantic, you havnt explained why, just what. If you do not wish to tell me, then just say.
    Dude. I wasn't meaning to be agressive. Damn transmoweb! I'm just really busy today (I've not posted anywhere but here!) and as such kept my posts as short as possible. No offense meant. Honestly!

    Sheesh. I've met you, why would I feel the need to be agressive towards you... oh, I see! ;)

    Oh, and the why "is because I've been told to and I like getting paid".

    Ok, the real reason is that some people have been screwing around with their config and providing themselves with internet access when they shouldn't. I've got a list of users who have the ability to do this and want to compare that list with everyone who's used the net ever. This should give me a list of "who's able to do this and has actually managed to connect to the net".

    [MH]

    Edited by Mike_Hunt at 14:34:11 24-05-2005
  • ssuellid 24 May 2005 14:35:02 19,142 posts
    Seen 2 days ago
    Registered 20 years ago
    tannerd link

    I was having the same trouble posting links the other day. Doing just the link screwed it up, hrefing it screwed up but adding the http seemed to work.

    Edited by ssuellid at 14:38:49 24-05-2005
  • Mike_Hunt 24 May 2005 14:36:39 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    DiscoMike wrote:
    I think the point some others earlier were trying to make is that NBTSTAT does not return usernames.

    The NETBIOS name is returned. (computer name)
    The Netbois name/computer name is the H0 number displayed in my example.

    Also returned is the U0 number, which is the user name. Now I don't know if that's also known as something else, but on all of our machines that number relates to the user of that computer. So by running that command I can resolve the user name. Sorry for not being clearer.

    [MH]
  • Mike_Hunt 24 May 2005 14:37:28 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    tannerd wrote:
    DiscoMike wrote:
    I think the point some others earlier were trying to make is that NBTSTAT does not return usernames.

    The NETBIOS name is returned. (computer name)

    NBTSTAT -A displays the Remote Machine Name Table, one entry of which is the username.

    See www.microsoft.com/resources/documentation/Windows/2000
    /server/reskit/en-us/prork/pref_tts_pjtk.asp

    would link, but I keep getting EG errors
    Thanks tannerd! Twice!

    [MH]
  • tannerd 24 May 2005 14:40:38 2,691 posts
    Seen 1 month ago
    Registered 18 years ago
    Something you might want to consider is importing the ip addresses into an access db, and selecting out the distinct entries. I imagine in the 20Mb file you are going to have a lot of duplicates. Or you are on a _very_ big network.
  • jellyhead 24 May 2005 14:41:27 24,355 posts
    Seen 2 weeks ago
    Registered 18 years ago
    I've a vbscript that takes the nbtstat data and outputs the username and the ip to a csv file.
    Do you want it?
    Would have told you earlier but the forum was down. grrrr.
    send me mail to djellyhead gmail com if you're interested Mike.
  • Nuttah 24 May 2005 14:42:41 1,840 posts
    Seen 9 years ago
    Registered 18 years ago
    no problem mike, as you say I dont know why you would be aggressive either! :)

    It looked like a irritated response, but emotions can be a tad difficult to work out in text, no harm done :)

    Tannerds batch file looks plausible, its a shame that the usernames (yes i'll accept nbtstat -A might list usernames!)doesnt have a unique identifier, would make your life a lot easier!



    Edited by Nuttah at 14:42:32 24-05-2005
  • Mike_Hunt 24 May 2005 14:47:12 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    jellyhead wrote:
    I've a vbscript that takes the nbtstat data and outputs the username and the ip to a csv file.
    Do you want it?
    Would have told you earlier but the forum was down. grrrr.
    send me mail to djellyhead gmail com if you're interested Mike.
    Does the pope shit in the woods?!

    Email on it's way!

    [MH]
  • Mike_Hunt 24 May 2005 14:47:49 23,524 posts
    Seen 2 years ago
    Registered 19 years ago
    Nuttah wrote:
    no problem mike, as you say I dont know why you would be aggressive either! :)

    It looked like a irritated response, but emotions can be a tad difficult to work out in text, no harm done :)
    Oh, I'm irriated alright. Just not with you!

    [MH]
  • tannerd 24 May 2005 14:48:05 2,691 posts
    Seen 1 month ago
    Registered 18 years ago
    my nbtstat comes out like:

    Name Type Status
    ---------------------------------------------
    ...
    TANNERD {03} UNIQUE Registered
    ...



    And I believe the {03} is the identifier for the username field. Ultraedit has a regexp feature that could probably pull it out, but as there is a vbscript solution, I guess there's no need.

    Edit: stupid angle brackets. Replace { and } with greater than and less than...

    Edited by tannerd at 14:48:33 24-05-2005
  • mrpon 26 May 2016 11:03:48 37,366 posts
    Seen 55 minutes ago
    Registered 15 years ago
    11 year bump!

    Trying rename a chunk of files in a folder from this:

    RT_Cblahblahblah.docx

    to

    Cblahblahblah.docx

    So essentially remove the RT_ bit.

    Any tips? I'm struggling with the ren command.
  • One_Vurfed_Gwrx 26 May 2016 11:06:53 4,468 posts
    Seen 2 hours ago
    Registered 15 years ago
    Rename RT_Cblah*.* Cblah*.* ?
  • Deleted user 26 May 2016 11:10:09
    REN *.* " *.*" " *.*"
    LFNFOR On
    FOR %v IN (*.*) DO REN "%v" %v
  • Deleted user 26 May 2016 11:10:50
    Above works for ALL files in the folder, removes the first three characters
  • Dirtbox 26 May 2016 11:14:09 92,595 posts
    Seen 21 hours ago
    Registered 19 years ago
    Post deleted
  • Deleted user 26 May 2016 11:18:50
    Now then now then
  • First Previous
Sign in or register to reply

Sometimes posts may contain links to online retail stores. If you click on one and make a purchase we may receive a small commission. For more information, go here.