OK, I need to set the IP address of a mac address from the ARP -A command into a variable.
Here's what I get from the arp -a command:
C:>arp -a
Interface: 192.168.1.17 --- 0xb
Internet Address Physical Address Type
192.168.1.1 74-41-01-42-aa-df dynamic
192.168.1.5 d8-d8-cb-23-28-ab dynamic
192.168.1.13 18-e6-f4-86-75-9e dynamic
192.168.1.14 20-9c-8f-3f-03-9b dynamic
192.168.1.255 ff-ff-ff-ff-ff-ff static
224.0.0.22 06-00-5e-00-00-16 static
224.0.0.252 01-05-5e-00-00-fc static
239.255.255.250 01-00-4e-7f-ff-fa static
255.255.255.255 ff-ff-ff-ff-ff-ff static
I need a batch file to find the line with the mac address of 18-e6-f4-86-75-9e, and then take the IP address listed to the left and set it as a variable.
You can use the find
command to isolate the line with the MAC address you want, then use the for
command extract the IP address:
@echo off
for /f "tokens=1 delims= " %%i in ('arp -a ^| find /i "18-e6-f4-86-75-9e"') do set ip=%%i
echo %ip%