DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Run Command On String, Returning Output
This is basically implementing a Unix-style filter in Windows Scripting Host.
var shell = WScript.CreateObject("WScript.Shell"); var exec = shell.Exec("tr a-z A-Z"); exec.StdIn.Write("hello, world"); exec.StdIn.Close(); WScript.StdOut.Write(exec.StdOut.ReadAll());
Watch out for deadlocks if you're writing huge amounts of data into the command, but it works for reasonable amounts of data (the buffer is probably something like 4K, but I've not tested...)