Function Reference

StderrRead

Reads from the STDERR stream of a previously run child process.

StderrRead ( process_id[, peek = false[, binary = false]] )

 

Parameters

process_id The process ID of a child process, as returned by a previous call to Run.
peek If true the function does not remove the read characters from the stream.
binary If true the function reads the data as binary instead of text (default is text).

 

Return Value

Success: Returns the data read. @extended contains the number of bytes read.
Failure: Sets @error to non-zero if EOF is reached, STDERR was not redirected for the process or other error.

 

Remarks

StderrRead reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen. During the call to Run for the child process you wish to read from the STD I/O parameter must have included the value of $STDERR_CHILD (4) for this function to work properly (see the Run function).
StderrRead does not block, it will return immediately. In order to get all data, it must be called in a loop.
Peeking on the stream does not remove the data from the buffer, however, it does return the available data as normal.
By default, data is returned in text format. By using the binary option, the data will be returned in binary format.

 

Related

StdoutRead, StdinWrite, StdioClose, Run, RunAs

 

Example


; Demonstrates StdoutRead()
#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

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

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