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

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
>
>
>

Re: oExec.StdOut after pipe Findstr by Wensi

Wensi
Fri Jan 07 13:54:19 CST 2005

My general questions is if oExec.StdOut can read lines after |findstr?
I tested my code with > output.txt. It works.
"Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message
news:245ACF6B-348F-460D-8AE6-A731675EF0F2@microsoft.com...
> 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
> >
> >
> >



Re: oExec.StdOut after pipe Findstr by Matthias

Matthias
Fri Jan 07 15:09:38 CST 2005

Tom Lavedas wrote:
> 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?
>
Hi Tom,

findstr behaviour is inconsistent. Due to docs it should be in regexp
mode by default. If you enter a search string with spaces it filters
to any of the words (OR). If you need an exact match a workaround is to
replace the spaces with dots or to put the search string in a file
and use the /G option - correct behaviour according to the help then.

Although it's unclear to me what Wensi expects from the ping-findstr
line.

--
Gruesse Greetings Saludos Saluti Salutations
Matthias
---------+---------+---------+---------+---------+---------+---------+