LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sending separate commands to a standalone executable and getting results back

I have a standalone executable that I can start in a DOS window and send commands to that are specific to the application. I would like to use the SYS EXEC vi to start this executable and then use the Standard input terminal to pass each command to the application and use standard out to capture the response.
 
When I run the vi the dos window appears with the name of the application but no prompt appears and it just sits there. Labview is also paused. Wait to complete is true. If I close the window labview continues on. If I stop the VI, my output is loaded with prompts from the application as if the someone is pressing the enter key.
 
If I run the VI with Wait to complete as false then the application pops up and closes imediatly. Will the sys ecec vi do what I intend or am I misinterpreting the use of this VI ?
 
the executable is called MANP.exe and the five commands are read from an array on the front panel.
 
Thanks for any help.
 
J.R.
 
 
 
0 Kudos
Message 1 of 12
(8,299 Views)
OpenG has a system pipes library that does this.  This library is still in the alpha stage, but you might have success with it.  You can install the attached package file (oglib_pipe-1.0alpha-1.ogp) using OpenG Commander.
JKI Blog
0 Kudos
Message 2 of 12
(8,289 Views)

I don't have your DOS program so I can't test my attachment, so maybe you can try it.  I made some modifications.  You don't need to wire in a number to N of the For Loop if you enable indexing on the array input (right click the terminal and select enable indexing).  I then deleted the index array function because it is not needed when indexing is enabled.  Indexing will choose the first array element and use it on the loop's first pass, then on the second pass the second element is chosen and used, and so on until the loop reaches the end of the array.  I also got rid of the sequence structure since it was not useful.  I moved the delay from the sequence structure to inside the for loop.  You cannot use a Stop button in a for loop, so I deleted it.  The loop will execute until the end of the array and then stop.  You cannot abort in the middle.  If you need to do this, you need to use a while loop instead.  It is not necessary to put a Stop vi at the end.  The vi will stop on its own when all code has been executed.

Try the attached vi and let me know if it works.

Message Edited by tbob on 08-23-2005 01:01 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 12
(8,290 Views)

I ran the VI and it still brings up the executable and nothing appears to happen. But when I close the app, the system response field is loaded with the prompts from the app like something is being repeatedly sent during that time.

 

I attached the screen capture of the VI after running and also what the app looks like when I run it manually.

 

0 Kudos
Message 4 of 12
(8,271 Views)
Looks like the system exec is trying to output some error message or something.  Try just sending one command.  Get that to work first.  Then you could work on getting a list of commands to work.  Sorry I don't have any other suggestions for now.
If you run the app from a DOS screen, does it prompt you for a command?  I think that the only thing you could do with System Exec is call the DOS program with command line parameters.  I'm not sure if wiring in a string into the standard input is like typing in a command from the program's prompt.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 12
(8,258 Views)
If I run the app standalone, I enter each command separately then a return. The app then prompts me again. That is shown in the second screen shot in the attachment I sent yesterday. This app also generates a log file as commands are entered. When I run the sys exec vi in wait mode the log file grows tremendously. On one pass it actually filled up my system disk to the point I got a warning that I was low on disk space. The file shows hundreds of unknown command errors. So I think something is getting sent repeatedly.
 
I also opened the front panel of this VI and tried running it. The same thing happens. As you stated I think this is intended to either run a single command with a parameter or there is a bug with sending strings using standard input. A colleague of mine recommended using this be he is only sending a single ping command and checking for response.
 
I was trying to think of a DOS based windows tool  command line interface that I could experiment with to see if I get the same results.
 
Oh well, I will have to look for another option Thanks for you help TBOB,
 
J.R.
0 Kudos
Message 6 of 12
(8,244 Views)
Dear jroberts,
 
Check this attachment. It is working 8-))). The C code reads a string, swaps bytes and prints result.
It seems to me your DOS program is waiting for additional activities.
 
Best regards,
Jack

Message Edited by EVS on 08-24-2005 09:02 AM


Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 7 of 12
(8,235 Views)

Hi Jack,

In my application the window stays up and does not close, I type in the command (I.E. enumerate) and press return and that command is processed. then the app returns a prompt. I noticed yours closes after each command is passed. I am thinking that this VI was not designed to be interactivly used in a DOS session. If you change the executable to echo the string typed in and then wait for another string instead of closing you might see what I am seeing?

 

J.R.

0 Kudos
Message 8 of 12
(8,217 Views)
You have to define "standart input" prior to system exec calling. Try to combine all commands separating CR-LF into one  standart input string and then call DOS program.
 
"I am thinking that this VI was not designed to be interactivly used in a DOS session. "  - Here you are right
 

Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 9 of 12
(8,210 Views)

Hi Jim,

 

Seems that the library is not compatible with 64-bit (we currently use LabVIEW 2016 64-bit for development). Is it possible to upgrade the library to 64-bit?

0 Kudos
Message 10 of 12
(2,430 Views)