jefhal Posted September 22, 2005 Share Posted September 22, 2005 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 More sharing options...
Valik Posted September 22, 2005 Share Posted September 22, 2005 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 More sharing options...
jefhal Posted September 22, 2005 Author Share Posted September 22, 2005 (edited) 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 September 22, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Developers Jos Posted September 22, 2005 Developers Share Posted September 22, 2005 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 machineProcessWait($PID) While 1 $line = StdoutRead($PID) If @error = -1 Then ExitLoop $cmdOUT &= $lineWend$rawIPC = $cmdOUTMsgBox(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 More sharing options...
jefhal Posted September 22, 2005 Author Share Posted September 22, 2005 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 More sharing options...
jefhal Posted September 23, 2005 Author Share Posted September 23, 2005 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now