LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CMD.EXE Output Not Showing up

I'm using system exec.vi to run a batch file to program a Xilinx CPLD using Impact. If I call my batch file from windows (double click the file name), I see the batch file run and the steps executing. When I run the same batchfile from LV 8, all I see is a blank cmd.exe window, but the batch file executes because the CPLD gets programmed.
 I need to be able to see the batch file steps running to verify the CPLD has programmed correctly. What in LV is preventing the batch file output from being displayed? (I've got the run minimized flag set to false in system exec.vi)
 How can the output be displayed?
 
Thanks.
 
0 Kudos
Message 1 of 13
(8,992 Views)
The thing you have to remember is that System Exec isn't the same as the command prompt. It's analogous to the "Run" command (Start -> Run) for Windows. Thus, you would need to wrap the execution of your batch file within a cmd process.
0 Kudos
Message 2 of 13
(8,983 Views)
The thing you have to remember is that System Exec isn't the same as the command prompt. It's analogous to the "Run" command (Start -> Run) for Windows. Thus, you would need to wrap the execution of your batch file within a cmd process.


Browser registered 2 button clicks...


Message Edited by smercurio_fc on 06-20-2008 01:40 PM
0 Kudos
Message 3 of 13
(8,982 Views)
Hi,
 Thank you for your suggestion, but that's exactly what I have, except the quotes around the batch string. I added the quotes and still no luck. All I see is a blank cmd.exe screen. When the batch file ends, the blank cmd.exe screen disappears and the rest of the vi continues execution. I know the batch file is running because I can watch the process start and stop if I have task manager open.
 
0 Kudos
Message 4 of 13
(8,960 Views)
Have you wired an indicator to the standard output tab on the System Exec.vi?

0 Kudos
Message 5 of 13
(8,952 Views)
No. Could that be the reason? I'll check it later on this weekend as my system is shut down right now.
0 Kudos
Message 6 of 13
(8,945 Views)
SysExec.vi is reentrant, so you probably won't see anything... Also, as you
will notice, the output is only updated, when the exe is terminated. Then
your buffer size also need to big enough.

If you'd use OGPipes, you can monitor the output while it runs. You can also
stop the process by sending CTRL+C to it, while it is running. It's much
more flexible.

Regards,

Wiebe.


0 Kudos
Message 7 of 13
(8,906 Views)
0048,

At the Command Line input node of the System Exec.VI, use /c or /K to show the batch file commands as they execute.  Using /c will close the Command Window when the batch file completes, /K will cause the window to stay open until the user closes it.  You must also wire a False constant to the Wait Until Completion? (T) input node of the System Exec.VI.  If the line echo off appears in the batch file, commands will not be displayed as they are run.  This is a property of the batch file, not LabVIEW; remove the line from the batch file if desired.  See Additional DOS Functions for System Exec.vi
for more information.  I hope this helps.




Message Edited by Pie56694 on 06-23-2008 11:25 AM
Message 8 of 13
(8,877 Views)

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?

0 Kudos
Message 9 of 13
(6,535 Views)

@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://forums.ni.com/t5/LabVIEW/Controlling-the-STDIN-STDOUT-of-a-legacy-application-in-LabVIEW/m-p/...

 

http://opengtoolkit.cvs.sourceforge.net/viewvc/opengtoolkit/pipe/

 

https://forums.ni.com/t5/Community-Documents/LV-Process-Windows-pipes-LabVIEW/tac-p/3656658

0 Kudos
Message 10 of 13
(6,527 Views)