Help bacth file!!
Results 1 to 8 of 8

Thread: Help bacth file!!

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Posts
    6

    Help bacth file!!

    Hello there!

    I,m doing my diploma course ,and for the pass this moduel I have to create this bacth file.
    I would be grateful if anyone could give me a bit of help!

    Create a batch file that will scan a network and identify all the NIC cars mac addresses. The Batch file will then produce a file(s) documenting each NIC card by manufacturer.
    Requirements:

    1. Program design(flow chart)
    2. Source code

    Thanx!!

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Posts
    309

    Batch

    Hi Milan30

    There are lots of batch file tutorials on OA, If you use the search function , you'll find them !


    i.e

    http://www.antionline.com/showthread...ighlight=batch

    http://www.antionline.com/showthread...ght=batch+file


    You could also use Google and find sites such as :


    http://www.experts-exchange.com/Oper..._20598964.html

    http://home.att.net/~gobruen/progs/d...dos_other.html


    http://www.geocities.com/pdc_net/tcp_ip_utilities.html

    http://www.iopus.com/guides/batch.htm

    http://www.merlyn.demon.co.uk/batfiles.htm


    *Also, dont post the same request on two different forums.Delete the other one.

    Dr_Evil

  3. #3
    Member
    Join Date
    Nov 2002
    Posts
    80
    Sounds more like a job for perl if you ask me.

    you will probably need to use the nbtstat command to get the mac addresses, some kind of loop
    such as

    for %%a in (1 2 3 4) do nbtstat -a 192.168.0.%%a

    Anyhow I see Dr_Evil has already posted you some links as am write this, more info there I expect.

  4. #4
    Junior Member
    Join Date
    Aug 2003
    Posts
    4
    Which OS do you have? You can find several tools in the different Operating Systems.

    The first part is easy:

    --------------------------------- Starting Code -------------------------------------
    rem Ping Host 1 (necessary for ARP, because ARP can only analyze Connections to Computers, which have been connected earlier)

    ping -n 1 192.168.0.1

    REM Analyzing the Connection with ARP and building a textfile
    echo -- Host 192.168.0.1 >ip.txt
    arp -a 192.168.0.1 >> ip.txt

    REM Now a loop from 2 to 254 for the rest of your Network
    for /L %%i in (2,1,50) do ping -n 1 192.168.0.%%i
    echo -- Host 192.168.0.%%i >ip.txt
    for /L %%i in (2,1,50) do arp -a 192.168.0.%%i >> ip.txt
    --------------------------------- Ending Code -------------------------------------

    Now you have the MAC-Adresses listed in the File ip.txt.

    But I need more Infos.
    - Which sort of table or File do you have for MAC <-> Manufacturers
    - Do You really need a batch-File or is it possible to create a VBS?
    Greetings from

    http://www.AntiOnline.com/sig.php?imageid=481[Shadow] White Admin [/Shadow]

  5. #5
    Junior Member
    Join Date
    Aug 2003
    Posts
    6
    Thanx to all of you for replay!

    White Admin

    I'm using win2kserver and win2profesional for the clients.
    I have to do this as a batch file.I must to thank you one more time for your all halp.
    For the Mac addreses i txt file.

    I made bach file how did you sugest ,but it's not working wery vell.
    I'not sure what i did wrong.

    ping -n 192.168.1.0

    echo--Host 192.168.1.0>ip.txt

    arp -a 192.1689.1>>ip.txt

    for /L%%i in (2,1,50) do ping -n 1 192.168.1 %%i

    echo--Host 211.26.167. %% >ip.txt

    For /L%%i in (2,1,50) do arp -a192.168.1.%% >>ip.txt

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Posts
    4,786
    the for command is the thing to use as whiteadmin said. this i think may simplify it.

    +=+=+=+=+=+=+=+

    net view >>all.txt
    for /F "delims=\\" %%X in (all.txt) do ping -n 1 %%X |find /I "reply" >>pg.txt
    for /F "tokens=3" %%Y in (pg.txt) do arp -a %%Y >>results.txt
    notepad results.txt

    +=+=+=+=+=+=+=+


    the mfg is indicated by the first 3 numbers in the arp address (you can figure something out by yourself):

    C:\>arp -a 10.0.1.88

    Interface: 10.0.0.20 on Interface 0x1000003
    Internet Address Physical Address Type
    10.0.1.88 00-90-27-b0-be-7a dynamic

    as you can see there's no need to echo the ip address as it's given in the return from ARP. (wasn't sure of that until i ran it)

    ------------------

    for /L%%i in (2,1,50) do ping -n 1 192.168.1 %%i

    echo--Host 211.26.167. %% >ip.txt

    you dont have a space between /L amd %%i. you also need a "." after 192.168.1 and the echo will have to be used in a "for" loop for the variable (almost...%% is not a var ) to change. but you dont have to do that anyway
    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

  7. #7
    Senior Member
    Join Date
    Nov 2001
    Posts
    4,786
    in the morning i regret it:

    after trying to help you with the answer, then going back and reading your response to whiteadmins's post...their going to (fail you/kick you out of school) for cheating if you hand this in. You obviously dont know diddlie-squat about dos commands.

    So as a pennance to you, the AO community and myself, So you can at least learn what it is that your using and give the correct answers when asked:

    white space is important in certain places.

    if you ran:

    echo--Host 192.168.1.0>ip.txt

    dos would tell you it cannot find "echo--host" or one of it's components. their must be a space between a command and its arguments. if you had that space all that would happen would be "--host 192.168.1.0>ip.txt" would be printed on the screen. what's being echoed needs to be seperated from the re-directer ">>" for it to be recognized as such

    ">>" will append data to an existing file. if the file does not exist it will create it.

    ">" will create a file and put the data into it. if the file already exists it will be overwritten.

    "|" is the pipe command. it will direct the output of one program as input to another

    "find" will search for a given string either in a file or from the command line. the flag "/I" tells it to be case insensitive. i used it because i was too lazy to run the ping command again to see how it was being outputted. you could use "Reply" without the "/I". the string your searching for must be enclosed inside of double quotes

    the -n after the ping command is a flag that requires a number. this tells ping how many times to try for an echo request

    a "FOR" statement" compleats before the bat file can go on to the next statement. If you use a for loop to set a var the next statement will only be aware of the last value it was set too.

    i wrote this tutorial to give people a fun way to learn the FOR statement:

    http://www.antionline.com/showthread...hreadid=238228


    If you don't find these things fun you shouldn't even be concerned about a deploma. What could one accomplish? Get you a job in a field you wouldn't be happy in?
    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

  8. #8
    Junior Member
    Join Date
    Aug 2003
    Posts
    6
    Hello Tedob1!

    I have to tanks you for all your help!
    You are apssolutly right when you said that they will fail me if I hand this in,but i have to add on this i,m still beginer ,i was traying llearn as fast as i can,but i fell very confused.
    Last two days i m trayin to get working this bach file ,but whatever i try it not working
    I had read million"s time your replay traying to understand how to complite that.

    I can't figure out where I m wrong.

    But one more time.Thank you so much to all of you who replyed!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •