UnderTheRadar
IS-IT--Management
I have a command that outputs a plethora of information and I only need one word out if it.
In DOS for example, if I only wanted the IP address of a hostname, I'd write two batch files something like this:
getIP.bat
parseIP.bat
BTW, I just through this together as an example. I'm sure there's a way to do it with only one script, and I'm not using ping or trying to get an IP address of a hostname.
So anyway, now I'm trying to apply the same logic in VBScript, but I'm not sure how to retrieve only the "token" I need out of these results, not knowing the value of the token of course. I just want the value that comes after the "Reply from".
Here's what I have so far:
Any help will be greatly appreciated. I'm sure it's simple, but I searched high and low and I must not be asking the right question.
Thanks in advance.
In DOS for example, if I only wanted the IP address of a hostname, I'd write two batch files something like this:
getIP.bat
Code:
@echo off
for /f "tokens=3 delims=: " %%i in ('parseIP') do echo %1 %%i
parseIP.bat
Code:
@echo off
ping -n 1 %1 | find "Reply from"
BTW, I just through this together as an example. I'm sure there's a way to do it with only one script, and I'm not using ping or trying to get an IP address of a hostname.
So anyway, now I'm trying to apply the same logic in VBScript, but I'm not sure how to retrieve only the "token" I need out of these results, not knowing the value of the token of course. I just want the value that comes after the "Reply from".
Here's what I have so far:
Code:
SET objShell = CreateObject("Wscript.shell")
DIM objExec, strResult
SET objExec = objShell.Exec("ping -n 1 localhost")
WHILE objExec.Status <> WshFinished
'wait until command completes
WEND
strResult = objExec.StdOut.ReadAll
'just to see what's happenin
Wscript.Echo strResult
Any help will be greatly appreciated. I'm sure it's simple, but I searched high and low and I must not be asking the right question.
Thanks in advance.