Re: How to parse output from a command



Try this

Function Ping_Host(Target)

Dim oExec, CommandLine

CommandLine = "Ping -n 1 -w 100 " & Target

Set oExec = objShell.Exec(CommandLine)

'## Examine output of exec command line by line (kill loop when no more
input)
Do Until oExec.StdOut.AtEndOfStream
Input = oExec.StdOut.ReadLine
' '## If host replies, set ping_host to 1 then Exit
if InStr(Input, "Reply") And not Instr(input, "unreachable") Then
Ping_Host = True
Exit Function
End If
Loop
Ping_Host = FALSE

End Function


"Don" <Don@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4EFA5A17-EB52-4DD7-ABA4-CEA1F6477505@xxxxxxxxxxxxxxxx
>I realize this is more of a windows shell scripting questions, but this new
> menu thing... well, it sucks quite frankly.
>
> Anyway, how would I get the same results out of VBScript, that I would
> from
> this DOS batch command?
>
> for /f "tokens=3 delims=: " %i in ('ping -n 1 localhost ^| find "Reply
> from"') do @echo %i
>


.



Relevant Pages

  • Re: What does the statement "exec >myfile.dat" mean?
    ... In article, Peter Hanke wrote: ... With no command to exec, the exec command will respawn the current ... Using descriptor duplication, and redirection, I can direct segments ...
    (comp.unix.shell)
  • Re: Redirection of STDERR
    ... you'd want a command to be ... the exec command by itself should just ... I prefer to save things like the named pipe syntax for the really ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: shell commands seperated by | wont run
    ... when invoking a secondary command processor in the way I proposed. ... Set oShell = CreateObject ... Dim oExec, sOut ...
    (microsoft.public.scripting.vbscript)
  • Net::SSH exec command on remote host
    ... I try to use Net::SSH to exec command on remote host. ... A session was ... It always failed to get the output of second cmd no matter what ...
    (comp.lang.ruby)
  • Re: system command returns 32512
    ... The system command forks a child process and then it calls the exec ... I think the exec command is failing. ... Can it be due to any memory error? ...
    (comp.unix.aix)

Loading