Sign in to follow this  
Followers 0
59FIFTY

Run a script and read output

9 posts in this topic

Hi there,

I have a little problem, I was trying to read the output of and autoit script from another script.

I.e. Script A starts Script B and reads the output of Script B, but I dont know how to do it. I tried starting Script B over the console with Autoit3.exe /script but I cant write to the console from Script B

Any suggestions?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Take a look at the Std*() functions in the helpfile.

StdinWrite ( process_id[, string])

StdinWrite ( process_id[, string] )

StdoutRead ( process_id[, count[, peek = false]] )

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

scriptA.exe

#include <Constants.au3>

$file = @ScriptDir & "\scriptB.au3"

If @Compiled = 1 Then
    $exeFile = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file & '"')
    $PID = Run($exeFile, @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
Else
    $au3File = FileGetShortName($file)
    $PID = Run(@AutoItExe & " " & $au3File, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
EndIf

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

scriptB.au3

MsgBox(0, "message from B", "Hi im scriptB.au3")
$PID = ProcessExists("scriptA.exe")
StdinWrite($PID, "hi from B through STDIN")

It calls scriptB and scriptB displays the MessageBox, but the While loop with the StdoutRead doesnt get anything, why? Is it a problem with

$PID = ProcessExists("scriptA.exe")

Share this post


Link to post
Share on other sites

no idea?

Share this post


Link to post
Share on other sites

It's still not working, and I'm a 99% sure its because of

$PID = ProcessExists("scriptA.exe")

Share this post


Link to post
Share on other sites

It's still not working, and I'm a 99% sure its because of

$PID = ProcessExists("scriptA.exe")
me too...

per help

Reads in a number of characters from the STDOUT stream of a previously run child process.

script "A" is not a child of script "B"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

That's what I was guessing, no child, so it doesnt work, but somehow I have to output data into the regular STDOUT if a script. Ony question is how? There is no cout>> :)

Share this post


Link to post
Share on other sites

Try using ConsoleWrite in scriptB instead of StdinWrite.

:)

Share this post


Link to post
Share on other sites

Now I'm ashamed..... Thanks for the help

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  
Followers 0