EvilZone
Programming and Scripting => C - C++ => : lsquared November 30, 2014, 07:44:54 AM
-
I have come upon an idea with which I have little experience. I essentially want to run a Win32 console executable and send input and retrieve output all from a separate C/C++ application. Before I start researching on my own I thought I'd post here and see if you guys have any experiences that would maybe help with this. Not looking for an answer but maybe a thought or technology that could help.
In pseudo code (well my version of pseudo), here's what I was thinking of the C/C++ application:
constructor/main method
start exe/process
void send_cmd(command)
<way to send text input to external console application>
data get_output()
<way to retreive stdout from console>
void destroy()
end exe/process
Any help greatly appreciated.
-
The term you're looking for is IPC or Inter Process Communication. Theres lots of ways to do it on a linux system, not sure about the methods to do it on windows(though I know windows does do it own IPC with SMB so theres bound to be some methods).
The lazy man route would be to setup a file, and just read/write to that file. Or a network socket.
If all youre talking about is sending input to the stdin of the second process, then thats pretty easy many guides abound if you google.
-
You will hve to look into pipeing, streams and popen.
this has some good info
https://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c