squadjot Posted December 13, 2009 Share Posted December 13, 2009 (edited) Hi great program.. i have a little problem tho.I would like to read the contents of CMD-prompt-window while its processingi tried following to get an "realtime" output from the window, but it seems like the app freezes until the ping test is fully done.. #include <Constants.au3> Local $file = FileOpen("test.txt", 1) Local $foo = Run('ping cola.jp', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($foo) If @error Then ExitLoop $message = "" $message = $message & $line & @LF FileWriteLine($file, $line) sleep(200) WendThis does not work, the file gets written only at the end / when the CMDprompt is fully doneDoes anyone know a trick how to do it without being stuck while the CMD Prompt is processing??ps. seems like this postmight be about similar problemThanks! Edited December 13, 2009 by squadjot Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 14, 2009 Share Posted December 14, 2009 Can't duplicate your symptoms. What makes you think it "freezes", and what makes you think the file is only written to at the end? How are you checking that? You should be closing the open file with FileClose($file). That is not causing any symptoms because all open handles are closed when the script exits, but is good practice. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
squadjot Posted December 14, 2009 Author Share Posted December 14, 2009 Can't duplicate your symptoms. What makes you think it "freezes", and what makes you think the file is only written to at the end? How are you checking that?You should be closing the open file with FileClose($file). That is not causing any symptoms because all open handles are closed when the script exits, but is good practice. Well i had a 3rd part app reading on that output file ever 20 ms.. Nevermind i found another way to do all this. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 14, 2009 Share Posted December 14, 2009 Well i had a 3rd part app reading on that output file ever 20 ms..Because you did not Open/Write/Close the file each time you added a line it is being held open for write the whole time. The data is going to the file in the mean time, but can't be read until the file gets closed. If you don't open a file before hand, and simply put the string path in $file, then each you call FileWriteLine() AutoIt will open/write/close the file. That might work better for you if intermediate reads are required. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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