Jump to content

stdout_child is truncating some output


jefhal
 Share

Recommended Posts

I'm trying to use stdout_child with a run command to get back the output of an ipconfig command. However, more times than not, the last 30% of the output is lost. Here's what I'm doing:

#include-once
#include <array.au3>
#include <Constants.au3>
dim $cmdOUT, $strComputer = "sysl560"
 
$PID = run(@comspec & ' /k ' & "\\student2\apps$\_bin\utils\psexec.exe \\" & $strComputer & " ipconfig /all",@TempDir,"",$STDOUT_CHILD)
$cmdOUT &= StdoutRead($PID)
$rawIPC = $cmdOUT
MsgBox(1,"$cmdOUT=",$rawIPC)

I can run this command in a dos box without any errors:

psexec \\sysl560 ipconfig /all

and I always get the correct output. Am I using stdout_child incorrectly, or are there some hidden limitations? I tried runwait instead of run, but runwait does not yet accept the stdout_child parameter (or does it?)

Thanks

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

You are capturing the output once. You need to capture the output in a loop to get it all or use ProcessWaitClose() before you read the output so that you can get all of it. What you have now is a race condition: You want to read all the data but you are hoping the application will run in the milliseconds of time between the end of the Run statement and the beginning of the read statement. This is obviously not going to work.

Link to comment
Share on other sites

You are capturing the output once. You need to capture the output in a loop to get it all or use ProcessWaitClose() before you read the output so that you can get all of it. What you have now is a race condition: You want to read all the data but you are hoping the application will run in the milliseconds of time between the end of the Run statement and the beginning of the read statement. This is obviously not going to work.

Thanks Valik! I tried it, but it still chopped off at the same place. I believe that the additional factor of the "psexec" is causing the PID's to get crossed or lost. Here's what I tried, but it did not work...

#include-once
#include <array.au3>
#include <Constants.au3>
dim $cmdOUT, $strComputer = "sysl070"
$PID = run(@comspec & ' /c ' & "\\student2\apps$\_bin\utils\psexec.exe \\" & $strComputer & " ipconfig /all",@TempDir,"",$STDOUT_CHILD)
;$PID = run(@comspec & ' /c ' & "ipconfig /all","","",$STDOUT_CHILD); unremark this line for testing on local machine
ProcessWait($PID) 
$cmdOUT &= StdoutRead($PID)
$rawIPC = $cmdOUT
MsgBox(1,"$cmdOUT=",$rawIPC)

How would I capture the process in a loop? Not sure where the loop would exist?

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

  • Developers

Try:

#include-once

#include <array.au3>

#include <Constants.au3>

dim $cmdOUT, $strComputer = "sysl070"

$PID = run(@comspec & ' /c ' & "\\student2\apps$\_bin\utils\psexec.exe \\" & $strComputer & " ipconfig /all",@TempDir,"",$STDOUT_CHILD)

;$PID = run(@comspec & ' /c ' & "ipconfig /all","","",$STDOUT_CHILD); unremark this line for testing on local machine

ProcessWait($PID)

While 1

$line = StdoutRead($PID)

If @error = -1 Then ExitLoop

$cmdOUT &= $line

Wend

$rawIPC = $cmdOUT

MsgBox(1,"$cmdOUT=",$rawIPC)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Try:

Looks good so far! I'll test it at work in the am. By the way, what does &= do? Does that append the new value to the last value or concatenate it? I searched for this in help, the forum, and on the web, but it is too short to return a search. Are there other devices like this?...
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Try:

Well, unfortunately, it is still truncating the last portion of the output. In fact, it always truncates at the same spot. Almost like it is a character count thing. Back to clipput/clipget...
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
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...