Jump to content

StdoutRead() Question


Recommended Posts

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; 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...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Edited by HockeyFan
Link to comment
Share on other sites

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; 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...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Just don't show it if it's empty:
If StringStripWS($line, 8) <> "" Then MsgBox(0, "STDOUT   read:", $line)

Edit: Actually, I like the answer from Hubertus72 better...

:P

Edited by PsaltyDS
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
Link to comment
Share on other sites

try this:

#include <Constants.au3>
Local $line = "", $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While Not @error
    $line &= StdoutRead($foo)
WEnd
MsgBox(0, "STDOUT read:", $line)

$line = ""
While Not @error
    $line &= StderrRead($foo)
WEnd
MsgBox(0, "STDERR read:", $line)

MsgBox(0, "Debug", "Exiting...")
Thanks Hubertus72. :)

Not sure I completely comprehend the concept :( , still working it through :idea: , but it does what I need. Thanks again!! :P

Link to comment
Share on other sites

  • 4 weeks later...

When I ran this I got the directory listing for a directory of choice. I did not have foo.bar on my machine naturally. When I ran it with redirection or with a non command interpreter .exe I got NO output. I am not sure why

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; 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...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...