Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 将IP地址转换为mac地址cmd_Batch File_Arp - Fatal编程技术网

Batch file 将IP地址转换为mac地址cmd

Batch file 将IP地址转换为mac地址cmd,batch-file,arp,Batch File,Arp,我已经找到了很多关于这个问题的答案,但不是批量的。 这是我得到的 C:\Users\Colton>arp -a Interface: 192.168.1.12 --- 0xb Internet Address Physical Address Type 192.168.1.1 74-44-01-42-aa-df dynamic 192.168.1.11 20-7c-8f-3f-03-9b dynamic

我已经找到了很多关于这个问题的答案,但不是批量的。 这是我得到的

C:\Users\Colton>arp -a

Interface: 192.168.1.12 --- 0xb
  Internet Address      Physical Address      Type
  192.168.1.1           74-44-01-42-aa-df     dynamic
  192.168.1.11          20-7c-8f-3f-03-9b     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.252           01-00-5e-00-00-fc     static
  224.0.0.253           01-00-5e-00-00-fd     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static
我只需要自己获取givin IP地址的Mac地址。我认为findstr命令是我所需要的,但我不知道如何使用它

然后,我会使用以下命令将其设置为变量:

for /f "delims=" %%A in ('command_that_I_need') do set "macaddress=%%A"
echo the mac address of 192.168.1.11 is %mac%.
我不知道如何从arp命令解析出Mac地址,因为这就是我所需要做的

set "ip=192.168.1.11"
for /f "tokens=2" %%a in ('arp -a ^| findstr /b /l /c:"  %ip% "') do set "mac=%%a"
echo %ip% = %mac%