看我这里
http://www.cn-dos.net/forum/viewthread.php?tid=52933&fpage=2
11楼的说明!~
是你在set gw=%%i就已经把空格带进去了
结果就是“空格+Default Gateway”
正确应该这样写:
@echo off
for /f "tokens=2 delims=:" %%i in (`ipconfig ^| find "Default Gateway"`) do set gw=%%i
for /f "tokens=2 delims= " %%i in (`arp -a ^| findstr "\<%gw:~1%\>"`) do echo %%i
pause
%gw:~1%用于把最前面带进去的空格去掉
Last edited by Hanyeguxing on 2010-12-6 at 15:16 ]
Look at my place
http://www.cn-dos.net/forum/viewthread.php?tid=52933&fpage=2
The explanation on floor 11!~
It's because you have already brought the space in when setting gw=%%i
The result is "space + Default Gateway"
The correct way should be written like this:
@echo off
for /f "tokens=2 delims=:" %%i in (`ipconfig ^| find "Default Gateway"`) do set gw=%%i
for /f "tokens=2 delims= " %%i in (`arp -a ^| findstr "\<%gw:~1%\>"`) do echo %%i
pause
%gw:~1% is used to remove the leading space that was brought in