Jump to content
Sign in to follow this  
59FIFTY

Run a script and read output

Recommended Posts

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

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

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

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  

×
×
  • Create New...