suthers Posted August 24, 2009 Posted August 24, 2009 Hi All, I launch a child process that take a long time to exit. I wish to trap its exit code. Using RunWait() this is easy, but the script is haltes while it waits for the child process. Using Run() instead I can trap the StdOut & StdIn streams, but can't figure out a way to get the exit code. Is there a way? Shalom Bill
PsaltyDS Posted August 24, 2009 Posted August 24, 2009 (edited) Hi All,I launch a child process that take a long time to exit. I wish to trap its exit code. Using RunWait() this is easy, but the script is haltes while it waits for the child process. Using Run() instead I can trap the StdOut & StdIn streams, but can't figure out a way to get the exit code.Is there a way?ShalomBillThere was a possible solution recently posted by a certain rakishly good-looking antarctic water fowl...La chiam! >_< Edited August 24, 2009 by PsaltyDS 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
suthers Posted August 25, 2009 Author Posted August 25, 2009 That rakishly good-looking antarctic water fowl knows his stuff :-) My concern is that the process may not exist for long enough to grab the handle. The child process I'm launching in a command-line FTP utility. If the host is not accessable it exits extremely rapidly. I have actually got a messy workaround operating. Basically I launch, using run(), a second AutoIT process, which then launches my utility via RunWait(). The second process captures the exit code & saves it to a file, then exits. When the main script detects the second has closed, it picks up the code from the file. I'm now looking at eliminating the tempfile by using STD streams to communicate between the two autoIT processes....but if your solution can grap the process handle in time it will be soooo much neater. If it works, how do I give credit to yourself and the author of the AutoITWrapper UDFs in my script? Shalom Bill
suthers Posted August 27, 2009 Author Posted August 27, 2009 It works a treat :-) Seems to grab the handle even for short duration processes. Now I can get StdErr and Exit code. Thank you!!! Shalom Bill PS I just discovered that FTP uploading functionality has been added to the std distribution from 3.3.1.0, so this whole effort to utilise a 3rd party FTP app may be moot..... Arh well...it was a good exercise :-)
PsaltyDS Posted August 27, 2009 Posted August 27, 2009 Seems to grab the handle even for short duration processes.Glad it worked for you. I ran a timer on the _ProcessGetHandle() function, and it returned in under 500us every time. So that's probably not something to worry about. 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
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