Jump to content
Sign in to follow this  
jfitzger

capture stdout from run foo.exe

Recommended Posts

jfitzger

I have tried a couple of ways to capture STDOUT from an exe but have not been succesful.. Any help would be appreciated

Here is what I have tried

Local $runPID = Run (@ComSpec & " /c " & 'hostname > C:\hostname.cfg') ; put it to a file to parse later from a dos command

#include <IE.au3>

#include <file.au3>

#include <array.au3>

#include <ClipBoard.au3>

#include <Constants.au3>

Local $foo = Run ("c:\test.exe test1 test2 ")

MsgBox (0,"test", "this is the PID test.exe" & $foo) ;Got the PID fine

Local $output = StdoutRead($foo)

MsgBox (0,"stdoutread","this is camip" & $output) ;did not get any output

Share this post


Link to post
Share on other sites
Pain

Look at the Run parameters.

2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream.

Share this post


Link to post
Share on other sites
PsaltyDS

I have tried a couple of ways to capture STDOUT from an exe but have not been succesful.. Any help would be appreciated

Here is what I have tried

Local $runPID = Run (@ComSpec & " /c " & 'hostname > C:\hostname.cfg') ; put it to a file to parse later from a dos command

#include <IE.au3>

#include <file.au3>

#include <array.au3>

#include <ClipBoard.au3>

#include <Constants.au3>

Local $foo = Run ("c:\test.exe test1 test2 ")

MsgBox (0,"test", "this is the PID test.exe" & $foo) ;Got the PID fine

Local $output = StdoutRead($foo)

MsgBox (0,"stdoutread","this is camip" & $output) ;did not get any output

You need your $STDOUT_CHILD parameter, as already pointed out.

I haven't tested it, but because you are using redirection (">") on the actual command line, I don't think you are going to get that data anyway.

If you need to see the standard out data, and then later need it in the file, take the redirection off and have the AutoIt script write it to file after you get it all from StdOutRead().

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
jfitzger

Look at the Run parameters.

2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream.

what is the handle? The handle you get back seems to be for the run command not the child

Share this post


Link to post
Share on other sites
PsaltyDS

what is the handle? The handle you get back seems to be for the run command not the child

In your example, $RunPID will be the PID of the instance of CMD.exe that is running (specified by @ComSpec).

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×