Extract something from a output - is this possible .?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
prabhu_kar
Posts: 2
Joined: 29 Sep 2008 12:14

Extract something from a output - is this possible .?

#1 Post by prabhu_kar » 29 Sep 2008 12:23

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

greenfinch
Posts: 36
Joined: 17 Jul 2008 07:37

#2 Post by greenfinch » 30 Sep 2008 10:54

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

prabhu_kar
Posts: 2
Joined: 29 Sep 2008 12:14

Thanks

#3 Post by prabhu_kar » 01 Oct 2008 13:28

Thanks for all the help .......

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#4 Post by DosItHelp » 08 Dec 2008 21:06

Or:

Code: Select all

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

:wink:

carlitos.dll
Posts: 11
Joined: 02 Jul 2008 07:42

#5 Post by carlitos.dll » 13 Dec 2008 12:50

The author has been removed this message.

Post Reply