Jump to content

$STDOUT_CHILD is not producing any results


Recommended Posts

 

Whenever I try to run this simple command it does not work with the constants at the end. If I remove the $STDERR_CHILD and $STDOUT_CHILD, the command works but of course I can't capture the text. I've tried many ways. I have the autoconstants include declared also. I looked at other topics in the forum and many are very old but didn't seem to be this scenario. AutoIt ver 3.3.12
 

Local $get = Run(@ComSpec & " /c ipconfig","",@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)

     While 1
        $sOutput = StdoutRead($get)
        If @error Then
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)
     WEnd
Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

#include<MsgBoxConstants.au3>
#include<AutoItConstants.au3>
Local $get = Run(@ComSpec & " /c ipconfig","",@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)

     While 1
        $sOutput = StdoutRead($get)
        If @error Then
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)
        Run("notepad.exe")
        Send($sOutput)
     WEnd

This code worked well for me.  What kind of error are you getting?

Link to comment
Share on other sites

Ah, I'm stupid for not noticing that. The script wasn't giving an error at all it was running through and not outputting anything. The problem was the the msgbox. Instead of giving me an error because I didn't include MsgBoxConstants.au3 it just seem to ignore it so the script just ran and did nothing. Normally it should say their is a variable not defined. Thanks for clarity and 2nd set of eyes. 

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

You could also do it like so:

#include<AutoItConstants.au3>

Local $get = Run(@ComSpec & " /c ipconfig","",@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)

$sOutput = ""

     While ProcessExists($get)
        $sOutput &= StdoutRead($get)
     WEnd

MsgBox(0, "Stdout Read:", $sOutput)

 

The original example also kind of fails in logic, as the first msgbox is empty everytime because there is no data...yet, and then i click ok and the second has data in it because by that time $sOutput has been populated.

#include<MsgBoxConstants.au3>
#include<AutoItConstants.au3>

Local $get = Run(@ComSpec & " /c ipconfig","",@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)

     While 1
        $sOutput = StdoutRead($get)
        If @error Then
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)
     WEnd

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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

×
×
  • Create New...