Jump to content
Sign in to follow this  
Guest cmjshen

capturing the STDOUT while displaying it in cmd

Recommended Posts

Guest cmjshen

Hi :

I know with beta code we can use StdoutRead to get the output from the

cmd.exe , but I also would like to display them in the cmd.exe window also.

Is there a way to achieve this ?

thanks :">

cmjshen

Share this post


Link to post
Share on other sites
DaveF

You can try TEE.EXE from the GNU Utilities for Win32.

TEE normally expects a file as a target, but in Windows you can use the special file name of CON , which is the console (screen).

That said, it's probably not going to behave like you'd expect, because the screen output is only going to appear in sips as AutoIt processes it, and for most programs the console window will disappear as soon as AutoIt is finished.

Here's my example:

$foo = Run(@ComSpec & ' /c dir *.exe | tee.exe CON', @ScriptDir, @SW_SHOW, 2)

While 1
    $line = StdoutRead($foo)
    If @error = -1 Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites
Gigglestick

If you like objects, you can also use the WScript.Shell with the Exec method. Check out the MSDN article on the WshScriptExec Object.

With this method, you can also capture StdOut and StdErr separately while the program is running (i.e. a progress bar or status dialog for robocopy?) and send text to StdIn.

I used it in a VBScript once, and sent a {SPACE} to StdIn when a command asked for it.

Edited by c0deWorm

My UDFs: ExitCodes

Share this post


Link to post
Share on other sites
Guest cmjshen

Thank you all DaveF and C0deWorm !

I will try your suggestions.

:whistle:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×