Sign in to follow this  
Followers 0
ken82m

STDOUTREAD [Solved]

4 posts in this topic

#1 ·  Posted (edited)

I've only had to use STDOUTREAD once or twice and not in quite a while.

Can someone please tell me why the code below doesn't return anything.

I'm at a loss as to why the example works but not this.

Thanks,

Kenny

My Test (Does Not Work)-

The only difference is the location of the MSGBOX's but they return nothing.

Local $foo = Run(@ComSpec & ' /c dir', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line

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


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

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

Example in Help File (Works)-

I first get a blank MSGBOX from STDOUTREAD and then another from STDOUTREAD containing the data.

Local $foo = Run(@ComSpec & ' /c dir', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line

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


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

MsgBox(0, "Debug", "Exiting...")
Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I got it, looked up a UDF and an old script I wrote.

The example might need a little revising in the help file.

-Kenny

Local $foo = Run(@ComSpec & ' /c dir', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
Local $line2
    
While ProcessExists($foo)
   $line = StdoutRead($foo, True)
   $line2 = StderrRead($foo, True)
WEnd
MsgBox(4096,"StdoutRead", $line)
MsgBox(4096,"StderrRead", $line2)
Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

Hello, I'm looking in the same direction and was puzzled by the help example.

Do I understand well your suggested code if I say that the second parameter (TRUE) in StdoutRead is peek parameter?

While ProcessExists($foo)
   $line = StdoutRead($foo, True)
   $line2 = StderrRead($foo, True)
WEnd

In such circumstances, the code should not wait until end of child process but poll stdout for new char.

I cannont obtain such a behaviour. My code (exemple below) is supposed to receive output from child while child is running, enabling to control the progress and showing it in a progress bar. Unfortunately, the code waits until child exits and prevents me from monitoring the progress. I get stdout only once when child exits. Do you know why?

Local $Button_1,  $msg
    GUICreate("My GUI Button"); will create a dialog box that when displayed is centered
    $Button_1 = GUICtrlCreateButton("Run .EXE", 10, 30, 100)
    
    $prg=GUICtrlCreateProgress(10,60,200,20)
    $in=GUICtrlCreateInput("",10,90,200,20)

    GUISetState()     
    $tst=0
   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                $tst=Run('test.exe','',0,$STDOUT_CHILD)   
        EndSelect
        if $tst<>0 Then

            While ProcessExists($tst)
                $line = StdoutRead($tst, True)
                GUICtrlSetData($prg,strlen($line))
            WEnd

        EndIf 
    WEnd

Share this post


Link to post
Share on other sites

@Happy...

The topic states "Solved" most "helpers" will not look inside this thread

Sorry, need to try again

8)


NEWHeader1.png

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