LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec reentrant execution or Non-reentrant

Is there a way to run System Exec non-reentrant?  It's block diagram is password protected.

 

I noticed a clone of System Exec running when I believe what is needed is non-reentrant.  With reentrant version running it doesn't always present the cmd.exe window to the operator.  I've added time delay (timeout /nobreak /t 3) and that didn't slow or stop multi-threading System Exec.

 

I'm using System Exec for a terminal commands (PuTTY) over Ethernet. Occasionally, I need to open a System Exec cmd.exe window, issue commands for the operator to read and confirm with the Enter key.  The command issued waits for user keyboard entry.

0 Kudos
Message 1 of 25
(2,168 Views)

Just create a non-reentrant wrapper VI. Don't change VIs installed with LabVIEW.

Certified LabVIEW Architect
0 Kudos
Message 2 of 25
(2,152 Views)

@richjoh wrote:

Is there a way to run System Exec non-reentrant?  It's block diagram is password protected.


Put it in a non-reentrant VI, and use that VI.

 


@richjoh wrote:

I noticed a clone of System Exec running when I believe what is needed is non-reentrant.  With reentrant version running it doesn't always present the cmd.exe window to the operator.  I've added time delay (timeout /nobreak /t 3) and that didn't slow or stop multi-threading System Exec.


Are you sure the cmd.exe doesn't show because the 'run minimized? (F)" boolean is set to true?

 

The System Exec.vi isn't the command line.

 


@richjoh wrote:

I'm using System Exec for a terminal commands (PuTTY) over Ethernet. Occasionally, I need to open a System Exec cmd.exe window, issue commands for the operator to read and confirm with the Enter key.  The command issued waits for user keyboard entry.


You'd need much more then System Exec.vi.

 

See Access to console output - NI Community

0 Kudos
Message 3 of 25
(2,151 Views)

wiebe@CARYA wrote:

@richjoh wrote:

Is there a way to run System Exec non-reentrant?  It's block diagram is password protected.


Put it in a non-reentrant VI, and use that VI.

 


@richjoh wrote:

I noticed a clone of System Exec running when I believe what is needed is non-reentrant.  With reentrant version running it doesn't always present the cmd.exe window to the operator.  I've added time delay (timeout /nobreak /t 3) and that didn't slow or stop multi-threading System Exec.


Are you sure the cmd.exe doesn't show because the 'run minimized? (F)" boolean is set to true?

 

The System Exec.vi isn't the command line.

 


@richjoh wrote:

I'm using System Exec for a terminal commands (PuTTY) over Ethernet. Occasionally, I need to open a System Exec cmd.exe window, issue commands for the operator to read and confirm with the Enter key.  The command issued waits for user keyboard entry.


You'd need much more then System Exec.vi.

 

See Access to console output - NI Community


If system exec was non-reentrant, how would putting it a reentrant VI help?  Wouldn't that make that VI behave mostly like a non-reentrant VI?  I mean, you can start as many instances as you want, but wouldn't each call to system exec still be non-reentrant and make each instance unable to complete?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 25
(2,133 Views)

Here's the issue. An exe (PuTTY) responds with a text to establish a security key (click "y" for Yes or disregard (click "n" for NO) ... Labview gets this text, cmd.exe window closes [X] and the text is output to the FP Indicator (standard output).  I need for Labview to not close the cmd.exe window so the user can respond using the keyboard to establish a security key.

 

I don't think wrapping System Exec in a non-reentrant VI solves my issue.  It's always been in a wrapper VI.   I must have been troubleshooting and was side-tracked as to why the cmd.exe window does not persist.  The boolean is set to "wait until completion" is True.  But any text to standard output means "completion" it appears.

0 Kudos
Message 5 of 25
(2,129 Views)

Correction i bold:

"Labview gets this text, cmd.exe window closes [X] and the text is output to the FP Indicator (error output)."

0 Kudos
Message 6 of 25
(2,121 Views)

@billko wrote:


If system exec was non-reentrant, how would putting it a reentrant VI help?  


It would not, but to his defence I understood it initially in the opposite direction too, and that would work.

 

However running System Exec reentrant will not solve the OPs problem. Each execution of System Exec creates a NEW process, with the command line as passed into. This process is NOT a command line but a bare process. It requires an executable that can be launched by the Windows system and will not do command line processing such as batch file execution and environment variable substitution. If you want that you have to prepend cmd.exe to the command line. This does launch cmd.exe and then passes the remaining parameters to it, and if there is another executable, batch file or command line command in that parameter list it will then be executed by cmd.exe.

 

But making System Exec reentrant or not will not allow to run the process interactively from LabVIEW. Instead one needs to redirect the standard input, output and error of the child process into a stream interface of some sort, that can then be controlled from LabVIEW. There are basically two ways to do that:

 

One I did many many moons ago in the form of an OpenG Pipe library, but that was never released although I know of several people who do use it successfully.

 

The other uses .Net and there have been several posts in the past proposing some more or less functioning VIs. 

 

In either case it isn't a very straightforward process, as you have to tinker with getting the response from the program, dealing with timeouts when the program doesn't respond in the time you think it should and all such things.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 25
(2,116 Views)

Are you running system exec with cmd /c to start your command?  Also, I believe you will have to add cd command to navigate to your putty directory before issuing the command to load the session.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 25
(2,115 Views)

OK, the setting is counter intuitive if you ask me but I get it now.  (I've made the same mistakes over years now. Setting the FP control "wait until completion?" to False makes the cmd.exe window persist.  Setting the control to True, any subsequent output is directed to the standard error Indicator.

 

I will likely forget this a year from now.  Thanks for all the help.

0 Kudos
Message 9 of 25
(2,079 Views)

Wait until completion = FALSE

 

launch the process and forget about it, return immediately to LabVIEW to do whatever else the diagram needs to do. LabVIEW has no control about that process anymore after that, it may run a second, an hour or forever. LabVIEW therefore also can NOT collect the standard output and standard error information from the process. The only error that can occur is when Windows tells LabVIEW that the process could not be created for some reason. Anything else is impossible, as by the time the process terminates, LabVIEW has long returned from the System Exec call and likely done a million other things already.

 

 

Wait until completion = TRUE

 

launch the process and wait until it completes. LabVIEW monitors the process through an event and sits there waiting until that event is triggered by the Windows kernel, indicating that the process has terminated. It then collects the error return code, the standard output and standard error information and passes it to the relevant indicators of the System Exec VI.

 

 

Reminder deleted because of Cloudflare protection claiming I was using prohibited language or something similar and preventing me to post.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 25
(2,049 Views)