06-20-2008 12:48 PM
06-20-2008 01:39 PM
06-20-2008 01:39 PM - edited 06-20-2008 01:40 PM
06-20-2008 02:54 PM
06-20-2008 03:31 PM
06-20-2008 04:04 PM
06-23-2008 03:10 AM
06-23-2008 11:22 AM - edited 06-23-2008 11:25 AM
10-15-2018 11:31 AM - edited 10-15-2018 11:48 AM
Hi all,
I do realize this in an ancient thread, but the issue is still valid and just cost me several hours of headache, mostly because I did not find any solution in this forum (please correct me if I overlook something though). So in order to provide the following information to others who might run into this kind of problem, I'm posting "a solution" here where most people would find it.
To summarize the problem, the "System Exec.vi" can EITHER block further execution of the calling labview code (by setting "wait for completion?" to TRUE) OR allow the output of whatever it runs to appear in the terminal, but not both! I find this highly couterintuitive to say the least. Moreover, I would imagine that the combination (wait until completion AND show the output on the terminal) is a rather common use case, as several threads in this forum bear witness.
Long story short, the only feasible way I found to achieve the desired behavior is this:
Run System exec.vi with "cmd /c start batchfile.bat"
This allows you to view the batchfile's output (live) while also waiting for its completion in the labview code. The only drawback I see is that the terminal does not exit automatically when the batchfile finishes. To circumvent this issue just put an "exit" command at the end of your batchfile.
Hope I can spare mankind some pain with this 😉
Cheers,
jan
EDIT: Ok, I found another drawback: LabView's CPU usage goes through the roof with this, even when the batchfile isn't acutally doing anything (e.g. "pause" command). Can anyone maybe explain what is happening here?
10-15-2018 12:23 PM - edited 10-15-2018 12:32 PM
@jqu wrote:
To summarize the problem, the "System Exec.vi" can EITHER block further execution of the calling labview code (by setting "wait for completion?" to TRUE) OR allow the output of whatever it runs to appear in the terminal, but not both! I find this highly couterintuitive to say the least. Moreover, I would imagine that the combination (wait until completion AND show the output on the terminal) is a rather common use case, as several threads in this forum bear witness.
I agree that NI should have a way to do both natively. For instance a copy process from the command line may show the status of the copy once a second. This is a bad example because you can do native file copy on the files bits to get progress but it is just an example of a time when you'd want to get the running status of a command. For this I've found the OpenG pipes API to work well enough. I even implemented a GUI for Robocopy using this and it seems to work well. With this you can get the string of the command prompt periodically by polling it.
http://opengtoolkit.cvs.sourceforge.net/viewvc/opengtoolkit/pipe/
https://forums.ni.com/t5/Community-Documents/LV-Process-Windows-pipes-LabVIEW/tac-p/3656658
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord