JibsMan

StdOutRead, StdErrRead, no output!

5 posts in this topic

I'm using SciTE to write and test this script.

$iResult = RunWait(@ComSpec & ' /c "' & 'runtest.exe -i "'&$sVideo&'"', "c:\Test\Sample_Test\", @SW_SHOW, $STDERR_CHILD)
ProcessWaitClose($iResult)
Local $sOutput = StderrRead($iResult)
MsgBox(0, "Output", $sOutput)
UpdateLogFile("Output is ",&$sOutput)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;This works fine on my test system:
#include <AutoItConstants.au3>

$CMD = 'echo ipconfig /all && ipconfig /all'
Local $iPID = Run(@ComSpec & ' /c "' & $CMD & '"', @SystemDir, @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
Local $sOutput = StdoutRead($iPID)
MsgBox(0, "Output", $sOutput)

I get nothing in the MsgBox, but I get the text I'm looking for in the bottom panel that shows the script running. How do I get that text into the MsgBox? If I can see i there, I can write it to a file, which is the end purpose. I've tried @SW_HIDE with the above & $STDOUT_CHILD with StdOutRead($iResult), but that does not print to the bottom panel, so Stderr_child must be it.

The bottom test works fine, providing a $sOutput I can use.

I am obviously doing something wrong, or the console output from runtest.exe (pseudonym for the actual app which I did not write and cannot control) is just weird.

Thanks in advance for any help!

Jibsman

Share this post


Link to post
Share on other sites



9 minutes ago, JibsMan said:

I've tried @SW_HIDE with the above & $STDOUT_CHILD with StdOutRead($iResult), but that does not print to the bottom panel, so Stderr_child must be it.

I am a little lost with this statement. Care to elaborate or even better post something we can play with that isn';t working for you.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@JibsMan did you check HelpFile Example ?
You should use While Wend   Loop.

Local $sOutput = ""
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
    WEnd
    MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Hi Jos,

I figured out what I was doing wrong (with the help of another programmer).

I did not understand what @SW_SHOW and @SW_HIDE actually did. If I understand now, @SW_SHOW displays the console output in the bottom panel of SciTE, and @SW_HIDE hides it. If this is still incorrect, and if there are docs explaining it, can you give me a link or hint how to find it?

I changed RunWait to Run, assuming the ProcessWaitClose(iPID) would do the same thing. Using the $STDOUT_CHILD in Run and StdoutRead(iPID) worked. I think RunWait was causing issues.

The code below works for me!

$iResult = RunWait(@ComSpec & ' /c "' & 'runtest.exe -i "'&$sVideo&'"', "c:\Test\Sample_Test\", @SW_SHOW, $STDOUT_CHILD)
ProcessWaitClose($iResult)
Local $sOutput = StdoutRead($iResult)
MsgBox(0, "Output", $sOutput)

Thanks for your help!

Jibsman

SciTE.jpg

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

21 minutes ago, JibsMan said:

The code below works for me!

Don't think so ...  that has a RunWait in it which doesn;t return the process handle. :)

@SW_HIDE will set the Window property, and tell it not to show on the desktop and is totally unrelated to the STDOUT & STDERR output.
The text you see in the SciTE Outputpane is the AutoIt3Wrapper information and the output that came back from the Run() statement, both STDOUT and STDERR.

Jos 

 

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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