Sign Up

Details

This is a great tool! One thing that would help me for my current use case would be if there was another event fired when a command has completed. I *think* that should probably be the "Exited" event (or perhaps "Disposed"), but admittedly I haven't tested it yet.

What I am hoping to be able to do is call some cmdline tools (such as nipkg.exe) and be able to report StdOut & StdErr as the command is executing, then detect when it is complete. I don't see a way to tell that a command has finished in the current implementation (short of matching patterns in StdOut/StdErr, which is problematic if you can't predict all possible errors ahead of time). I definitely don't want to have to wait for a timeout.

Comments

Javier Ruiz Hi Phil. Thanks for the comment. This is something we've discussed. I think the few issues I see are related to, how do you know a command has sent finished sending data? Because data may come in via StdOut or StdErr, depending on the result, the user may need to specify the length of the expected data coming via StdOut and maybe to finish immediately after something is received StdErr. Also, maybe a timeout? Can you share some of your ideas?
  1
 •  Reply3 years
Phil Lundeen I copied the class and made the change locally to do what I was hoping to do. There were a couple tricks to it: * Needed to set the "EnableRaisingEvents" property of the process * Needed to add "& exit" to the end of my StdIn argument. The "& exit" was the extra tricky bit. For my testing, I am just calling a batch file with some sleep operations (well, technically, I'm doing 'ping' calls to force some waits). I wanted to be able to see the StdOut as the script executes, but then close once the script completes. The problem was that even when I Enabled Raising of Events, the wrapping "cmd.exe" process wasn't exiting, only the batch file that it was calling. So then I modified the StdIn argument from "sleep.bat" to "sleep.bat & exit", and now I can actually see the output as it updates and the process will automatically stop once the script completes. If there's a github project for this, I'd be happy to open a pull request.
 •  Reply3 years
Javier Ruiz Hi Phil, I just made the repo Public and linked it to the package page. We are using LabVIEW 2015 for compatibility. https://github.com/jvr-ruiz/JKI-.NET-System-Exec
  1
 •  Reply3 years
Javier Ruiz Hi Phil. New version is out with your changed included. Thanks for the great idea and examples you created.
  1
 •  Reply3 years

Please sign in to leave a comment.