China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-30 03:55
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Can everyone help improve the scanning of the local area network mac address and converting it to modiip View 2,134 Replies 3
Original Poster Posted 2008-08-24 12:39 ·  中国 上海 长宁区 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
I want to try to use
http://www.unixwiz.net/tools/nbtscan.html#download
The provided nbtscan and gnu sort to process the MAC addresses scanned in the local area network into the modiip format.

The obtained abc.txt
is
192.168.10.8 WORKGROUP\ONLY208 00:1f:3c:2d:5f:f6 SHARING
192.168.10.222 WORKGROUP\ONLY202 00:1f:3c:28:43:2c SHARING

But when processing at the end, only one record can be generated, because it is affected by the set replacement, I don't know how to deal with it, please help me modify it, thank you
mac.ini
001f3c28432c=192.168.10.222,ONLY202

.\arc\nbtscan-1.0.35.exe -m 192.168.10.0/24 | .\arc\sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 >>abc.txt
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims= " %%a in (abc.txt) do (
set mac=%%c
set ip=%%a
set cname=%%b
)
Call :modiip %mac::= %
goto eof
:modiip
set cname=%cname:~10,9%
echo %1%2%3%4%5%6=%ip%,%cname%>>mac.ini
pause
Floor 2 Posted 2008-08-24 12:52 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
```
@echo off
type nul>"mac.ini"
.\arc\nbtscan-1.0.35.exe -m 192.168.10.0/24 | .\arc\sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 >>abc.txt
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims= " %%a in (abc.txt) do (
set mac=%%c
set mac=!mac::=!
set cname=%%b
>>"mac.ini" echo !mac!=%%a,!cname:~10!
)
pause
```
Floor 3 Posted 2008-08-24 13:09 ·  中国 上海 长宁区 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
Floor 4 Posted 2009-02-19 01:20 ·  中国 四川 成都 电信
初级用户
★★
Credits 118
Posts 66
Joined 2006-08-18 16:04
19-year member
UID 60797
Gender Male
Status Offline
Post again


@echo off

:Address Scan
echo Intranet IP segment MAC address scan
echo.
echo If you don't want to scan, enter . To scan, enter the first three segments of the IP segment you want to scan (for example: 192.168.1):
set /p ipa=
IF /I '%ipa%'=='Y' goto ipend
echo.
echo Processing data, please wait a moment........
echo.
for /l %%i in (1 1 254) do start/b ping -n 1 -w 1 %ipa%.%%i>nul && echo Connected: %ipa%.%%i
arp -a|findstr /v "00-00-00-00-00-00"|more
arp -d
goto Address Scan
Forum Jump: