RE: oExec.StdOut after pipe Findstr by tlavedas
tlavedas
Thu Jan 06 18:53:01 CST 2005
I think the problem may be that the result from the 'findstr' is null so you
won't get any output. I believe your match string is faulty. If the test is
to determine if the ping failed, the search string should have been "Request
timed out". However, if the test is to find a success, the search string
would be something like "Reply from". But both of these are problematic in
that neither will always return a result.
What exactly are you trying to accomplish with this bit of code?
Tom Lavedas
===========
"Wensi Peng" wrote:
> Hello,
>
> Can Exec object read lines from standard out after a pipe in command-line?
> Below is my script. After I added |findstr in the command-line oExec does
> not read anything from screen.
>
> Any tips?
>
> Thanks,
> Wensi
>
>
> strCommand = "%comspec% /c ping -n 1 " & strComputer & "|findstr /i ""reply
> timed unknown"""
> set oExec = Wshshell.Exec (strCommand)
> Do Until oExec.StdOut.atEndofStream
> Wscript.Echo oExec.StdOut.Readline & " , " & Ucase(strComputer)
> Loop
>
>
>