Jump to content

trouble using stdout to read console output


Recommended Posts

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?

Link to comment
Share on other sites

#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)

Link to comment
Share on other sites

#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.
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...