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?
set var from arp output.....i'm not sure how
Moderator: DosItHelp
Re: set var from arp output.....i'm not sure how
you can put the output of arp to a file and use it as a variable there using
Code: Select all
@echo off
set arp=arp -a
%arp% | find /i "00-1C-C0-4A-ED-AD" >>output.log
for /f "tokens=1,2,3 delims= " %%G IN (output.log) DO set IP=%%G
echo %IP%
pause
del output.log