set var from arp output.....i'm not sure how
Posted: 26 Mar 2010 12:40
Ive been working on this batch file that searches a mac address and informs of the ip address belonging to the mac. I can use:
arp -a | find "00-1C-C0-4A-ED-AD"
from the command prompt to get an output of:
192.168.0.223 00-1c-c0-4a-ed-ad dynamic
I want my batch file to set the ip address to a variable (%IP%) to be used in the later part of the batch file. At the moment; I was trying this:
@ECHO OFF
FOR /F "tokens=2,3 delims= " %%A IN ('arp -a | find "00-1C-C0-4A-ED-AD"') DO IF "%%B"=="[%1]" SET PC=%%A
echo %%A
Doesn't work at all though. Am I going in the wrong direction completely here? Any Idea's?
arp -a | find "00-1C-C0-4A-ED-AD"
from the command prompt to get an output of:
192.168.0.223 00-1c-c0-4a-ed-ad dynamic
I want my batch file to set the ip address to a variable (%IP%) to be used in the later part of the batch file. At the moment; I was trying this:
@ECHO OFF
FOR /F "tokens=2,3 delims= " %%A IN ('arp -a | find "00-1C-C0-4A-ED-AD"') DO IF "%%B"=="[%1]" SET PC=%%A
echo %%A
Doesn't work at all though. Am I going in the wrong direction completely here? Any Idea's?