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-06-25 06:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Please everyone test! Get the MAC and submit it to the web page! View 2,342 Replies 13
Original Poster Posted 2006-12-14 22:08 ·  中国 广东 中山 电信
新手上路
Credits 15
Posts 8
Joined 2006-11-30 21:58
19-year member
UID 72185
Gender Male
Status Offline
Running mac.bat will generate the local MAC information into a c:\addmac.htm and run it. Using the automatic jump of this file, the MAC is submitted to mac.php for processing via GET!

It has been tested and works in win2003\xp\2000! But the c:\addmac.htm generated in win98 cannot save the MAC information

Please take a look at what the problem is!


:::mac.bat::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo
:::::::::If c:\ipconfig.txt exists, delete it
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::Run ipconfig /all command and save its content to ipconfig.txt
ipconfig /all >c:\ipconfig.txt

:::::::::If c:\MyMAC.txt exists, delete it
if exist c:\MyMAC.txt del c:\MyMAC.txt

:::::::::Query the line containing Physical Address in c:\ipconfig.txt and save this line to c:\MyMAC.txt
find "Physical Address" c:\ipconfig.txt >c:\MyMAC.txt

:::::::::If c:\addmac.htm exists, delete it
if exist c:\addmac.htm del c:\addmac.htm

::@echo <meta http-equiv="refresh" content="1;URL=http://192.168.1.1/mac.php?macinfo=">

echo "<meta http-equiv='refresh' content='1;URL=http://localhost:8080/mac/addmac.php?macinfo=" >>c:\addmac.htm

@echo off&setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%a in (c:\MyMAC.txt) do (
set c=%%b
if not defined a (<nul set/p pp=!c:~1,17!>>c:\addmac.htm&set a=1) else (<nul set/p pp=!pp!^|!c:~1,17!>>c:\addmac.htm)
)

echo "'>" >>c:\addmac.htm
start "" c:\addmac.htm

:::::::::If c:\ipconfig.txt exists, delete it
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::If c:\MyMAC.txt exists, delete it
if exist c:\MyMAC.txt del c:\MyMAC.txt

exit
::End::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Floor 2 Posted 2006-12-14 22:58 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Simply cannot obtain the MAC address at all
Floor 3 Posted 2006-12-14 23:00 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
There is a suggestion. If it's an internal network, can we change it to obtain the external network IP and then call OE to automatically send an email to the specified mailbox? In this way, we can obtain the IP in time for remote connection and control, and system maintenance will be more convenient. It feels like getting the MAC is not of much meaning.
Floor 4 Posted 2006-12-14 23:03 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
I'm afraid the FBI has its own ideas, right?
Hehe...
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 5 Posted 2006-12-14 23:19 ·  中国 广东 中山 电信
新手上路
Credits 15
Posts 8
Joined 2006-11-30 21:58
19-year member
UID 72185
Gender Male
Status Offline
Originally posted by fbi at 2006-12-14 09:08 AM:
Run mac.bat, which will generate a local MAC information into a c:\addmac.htm and run, using the automatic jump of this file, use GET to submit the MAC to mac.php for processing!

Tested feasible in win2003\xp\2000! But in win98 raw...


You look at the address bar after the addmac.htm jump parameters!

Floor 6 Posted 2006-12-14 23:34 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
http://localhost:8080/mac/addmac.php?macinfo="%20IPCONFIG.TXT|00-0E-A6-A0-73-86"
Floor 7 Posted 2006-12-14 23:34 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
So the MAC has come here.
Floor 8 Posted 2006-12-14 23:36 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Can it be submitted to a fixed webpage or FTP?
Floor 9 Posted 2006-12-15 04:32 ·  中国 北京 鹏博士BGP
中级用户
★★
Credits 404
Posts 179
Joined 2006-03-30 14:44
20-year member
UID 53056
Status Offline
```
@echo off & setlocal enabledelayedexpansion
del c:\addmac.htm >nul 2>nul

for /f "tokens=1" %%a in ('getmac /nh') do (
>>c:\addmac.htm echo "<meta http-equiv='refresh' content='1;URL=http://localhost:80/mac/addmac.php?macinfo="%%a"'>"
start "" c:\addmac.htm
goto start
)
:start
pause

```
Floor 10 Posted 2006-12-15 04:50 ·  中国 广东 中山 电信
新手上路
Credits 15
Posts 8
Joined 2006-11-30 21:58
19-year member
UID 72185
Gender Male
Status Offline
Originally posted by HUNRYBECKY at 2006-12-14 10:34 AM:
http://localhost:8080/mac/addmac.php?macinfo="%20IPCONFIG.TXT|00-0E-A6-A0-73-86"


addmac.php separates the MAC separated by "|" from the GET submission and then saves the relevant information!

I wonder if you guys have any better methods!

Floor 11 Posted 2006-12-15 05:10 ·  中国 广东 中山 电信
新手上路
Credits 15
Posts 8
Joined 2006-11-30 21:58
19-year member
UID 72185
Gender Male
Status Offline
But if there are multiple network cards (multiple MACs), it won't work!

[ Last edited by fbi on 2006-12-14 at 04:12 PM ]

Floor 12 Posted 2006-12-15 09:40 ·  中国 北京 海淀区 方正集团
中级用户
★★
Credits 404
Posts 179
Joined 2006-03-30 14:44
20-year member
UID 53056
Status Offline
You should take a look at the usage of getmac
Floor 13 Posted 2006-12-16 09:52 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
It's better to directly upload the .txt after ipconfig /all via FTP.
Floor 14 Posted 2008-03-30 21:39 ·  中国 浙江 嘉兴 平湖市 电信
初级用户
★★
Credits 157
Posts 67
Joined 2007-05-13 11:03
19-year member
UID 88378
Gender Male
Status Offline
@echo off & setlocal enabledelayedexpansion
del addmac.htm >nul 2>nul

For /F "tokens=2 delims=:" %%a in ('IpConfig /All^|Find /i "Physical Address. . . . . . . . . :"') do (
>>addmac.htm echo ^<meta http-equiv='refresh' content='1;URL=http://localhost:80/mac/addmac.php?macinfo="%%a"'^>
start "" addmac.htm
goto start
)
:start
pause
Forum Jump: