Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process piped input in vbscript

Status
Not open for further replies.

neualex

Programmer
Feb 26, 2008
53
US
If running the following line from a batch file:
dir | myScript.vbs

how can I process the piped input from the DIR command?

I know we can do:

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("%comspec% /c dir")
strOut = oExec.StdOut.ReadAll
WScript.Echo strOut

Just curious if VBScript can get process the piped input data.

Thanks,
neualex
 
Opsss never mind, I found it.

Dim tmp

' Now read the input stream.
tmp = WScript.StdIn.ReadAll()

' Try to write the result to the standard output stream.
WScript.StdOut.WriteLine("*** Output Filter demo ***")
WScript.StdOut.Write(UCase(tmp))
WScript.StdOut.WriteLine("*** End of input data ***")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top