Page 1 of 1

Extract something from a output - is this possible .?

Posted: 29 Sep 2008 12:23
by prabhu_kar
Hi ,

I have this wierd issue,

Iam going to remotely extract the IP address from test tool which we we ues. What I wanted was something which could do like

ipconfig /all |find "IP Address" > text.txt

this is currently doing
IP Address. . . . . . . . . . . . : 137.117.176.102
Can we just push the 137.117.176.102 part straight to the file ..

Is it possible , I am writing some clumsy C code in my test tool to do that , but it would be better if I execute this system command from C which would simply output my IP and then I pick it up .....

:roll:

Thanks
PS

Posted: 30 Sep 2008 10:54
by greenfinch
This is a bit of a kludge using a temp file but it works:

Code: Select all

setlocal

ipconfig | find "IP Address"> "%temp%\ipline.txt"
set /p ipline=<"%temp%\ipline.txt"
for /f "tokens=1-14 delims=: " %%a in ("%ipline%") DO set ipline=%%n

Thanks

Posted: 01 Oct 2008 13:28
by prabhu_kar
Thanks for all the help .......

Posted: 08 Dec 2008 21:06
by DosItHelp
Or:

Code: Select all

for /f "tokens=2,* delims=:. " %%a in ('"ipconfig|find "IP Address""') do set ip=%%b
echo.%ip%

:wink:

Posted: 13 Dec 2008 12:50
by carlitos.dll
The author has been removed this message.