Jump to content



Photo

stdout_child is truncating some output


  • Please log in to reply
5 replies to this topic

#1 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 22 September 2005 - 04:10 PM

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





#2 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 22 September 2005 - 06:31 PM

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.

#3 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 22 September 2005 - 08:15 PM

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, 22 September 2005 - 08:16 PM.

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

#4 Jos

Jos

    oh joy ...

  • Developers
  • 21,042 posts

Posted 22 September 2005 - 08:21 PM

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)


Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#5 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 22 September 2005 - 11:11 PM

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

#6 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 23 September 2005 - 07:41 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users