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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Command Line Data to a Pipe

Status
Not open for further replies.

rbri

Programmer
Jun 27, 2002
84
US
Hello Everyone

Does anyone know how to send the output from a command line to a pipe so I can send that output to a textarea in a .hta script instead of cmd opening its own window and put the output to that. I looked up the cmd command and according to that a "/A" sends it to a pipe but, I can not find out where the output is going. For example in Perl you can open a file handle and pipe the output to that then send the file handle to an array then write the array to the window inside your program. Any help will be greatly appreciated.

Thanks Randy
 
Thanks for your help but, I get the same result as if I did what I listed below and that is how I started.

Set objShell = CreateObject("WScript.shell")
objShell.Run "systemcommand"

What I am trying to do is something simular to "cmd.exe ipconfig" and have the output go to my window not the cmd window I am using a different command than ipconfig though, I am using a program that came with vendor software that runs at the command line I am trying to capture that output to my window. I might be missing something in the command that you referenced if so I would appreiate clarification.

Thanks Randy
 
You may want to use .Exec instead of .Run, which allows you to manipulate the stdio streams of the spawned console process from your script.
 
Thanks dilettante for your response but, that is what the link that PHV sent me to. I tried the .exec I get the same output as I do with the .run I probably need more options or I am reading the example wrong. The example shows

Set oExec = WshShell.Exec("yoursystemcommand")

the example used "calc" and if you do that the calculator opens but if you put in say "ipconfig" a cmd window just flashes open for a second then closes I am not sure what to do next. Are there more options associated with .exec

Thanks Randy
 
You may try this:
Set oShell = WScript.CreateObject ("WScript.shell")
Set oExec = oShell.Exec("ipconfig")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Do While Not oExec.StdOut.AtEndOfStream
strLine = oExec.StdOut.ReadLine
iPos = InStr(1, strLine, "gateway", 1)
If iPos > 1 Then
gateway = Trim(Split(strLine, ":")(1))
Exit Do
End If
Loop
WScript.Echo gateway
WScript.Quit

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank You everyone for your help that last example worked great. For my application I had to make a couple of changes but, other than that it worked great. Thanks again for your help.

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top