Jump to content
Sign in to follow this  
bobbintb

trouble using stdout to read console output

Recommended Posts

bobbintb

this is my code so far:

#include <Constants.au3>
#include <file.au3>
#Include <string.au3>
#include <array.au3>

Local $foo = Run(@ComSpec & " /c ipconfig/all", @SystemDir, @SW_HIDE, $STDOUT_CHILD)
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    $line=_StringExplode($line, @CRLF)
    _ArrayDisplay($line)
    Wend

this is so simple its killing me. i just want to get the output into an array to use for later. i cant seem to get the array to save outside the loop without it being empty. and the array is blank the first time which i dont want either. any ideas?

Share this post


Link to post
Share on other sites
TurionAltec

#include <Constants.au3>
#include <file.au3>
#Include <string.au3>
#include <array.au3>

Local $pid = Run("ipconfig /all", @SystemDir, @SW_HIDE, $STDOUT_CHILD)  ;ipconfig not internal to cmd, no need for @comspec
ProcessWaitClose($pid)      ;Easier than a stupid loop. Just wait for it to finish!
$output=StdoutRead($pid)
ConsoleWrite($output)
$array=StringSplit($output,@CRLF,1)
_ArrayDisplay($array)

Share this post


Link to post
Share on other sites
bobbintb

#include <Constants.au3>
#include <file.au3>
#Include <string.au3>
#include <array.au3>

Local $pid = Run("ipconfig /all", @SystemDir, @SW_HIDE, $STDOUT_CHILD)  ;ipconfig not internal to cmd, no need for @comspec
ProcessWaitClose($pid)      ;Easier than a stupid loop. Just wait for it to finish!
$output=StdoutRead($pid)
ConsoleWrite($output)
$array=StringSplit($output,@CRLF,1)
_ArrayDisplay($array)

thank you. i tried taking it out of a loop but i guess my brain just isnt working today.

Share this post


Link to post
Share on other sites
TurionAltec

I blame the Stdoutread example in the help file.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.