Jump to content
Sign in to follow this  
sysyphusjones

capturing stdout

Recommended Posts

sysyphusjones

I have been trying to capture stdout from the ms uptime CLI utility:MS uptime.exe

uptime.exe is in the same directory as my script fragment.

At a cmd window, I can redirect its output to a file so I think this ought to work.

Here it is:

#include <Constants.au3>

$result = Run(@ComSpec & " uptime.exe ", @ScriptDir, @SW_HIDE , $STDERR_CHILD + $STDOUT_CHILD)  

;MsgBox(0, "result", $result)    ; !!! HERE !!!

$line = StdoutRead($result) 

MsgBox(0, "UPTIME", $line)

For some reason my resulting dialog is empty?

Also I added a debug dialog (marked as !!! HERE !!! in the script) to establish that I was getting a process ID, which I am, but for some reason with this line added, my UPTIME dialog now contains a windows copyright message??

Thanks with any help

Share this post


Link to post
Share on other sites
martin

I have been trying to capture stdout from the ms uptime CLI utility:MS uptime.exe

uptime.exe is in the same directory as my script fragment.

At a cmd window, I can redirect its output to a file so I think this ought to work.

Here it is:

#include <Constants.au3>
 
 $result = Run(@ComSpec & " uptime.exe ", @ScriptDir, @SW_HIDE , $STDERR_CHILD + $STDOUT_CHILD)  
 
;MsgBox(0, "result", $result)   ; !!! HERE !!!
 
 $line = StdoutRead($result) 
 
 MsgBox(0, "UPTIME", $line)

For some reason my resulting dialog is empty?

Also I added a debug dialog (marked as !!! HERE !!! in the script) to establish that I was getting a process ID, which I am, but for some reason with this line added, my UPTIME dialog now contains a windows copyright message??

Thanks with any help

Just follow the example in the help for StdOutRead.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
BigDod

#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c uptime.exe ", @ScriptDir, @SW_HIDE , $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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.