After some searching, I don't think I've found a forum response that addresses my issue. Hopefully, I did not overlook something.
I have a LabWindows CVI tool that needs to interface (read from / write to) a launched executable on STDIO. Unfortunately, I'm unable to modify the aforementioned executable and must use it as is.
Launching the executable from LabWindows seems OK. I use the following command:
err = LaunchExecutableEx("cmd /c test -i InputCommands.ini", LE_SHOWNORMAL, &testHandle);
This "test.exe" gets initialized by "InputCommands.ini" and outputs a line of status information every second. Ideally, I would like to:
- monitor (read from STDO) the status
- based on read data, determine when to quit the test (write to STDI)
- record (read from STDO) the final status data.
I've seen many suggestions for redirecting Standard Output to a file from which I could simultaneously read and monitor. I've tried the redirection portion with the following command. This definitely redirects the output, but leaves me with the problem (1.) I describe below.
err = LaunchExecutableEx("cmd /c test -i InputCommands.ini > output.txt", LE_SHOWNORMAL, &testHandle);
My points of frustration are:
1. How do I send commands to this launched executable telling it to stop? I need to send 'q' followed by 'quit' to the program to stop the executable.
printf("q\n");
This method sends a 'q' to STDIO, which the launched executable blissfully ignores. It seems like I'm missing the obvious, which is no doubt true...
2. Is there some way to directly read the Standard Output without the interim step of redirecting to a file?
I appreciate the thoughts.