Author Topic: IO with external process  (Read 1371 times)

0 Members and 1 Guest are viewing this topic.

Offline lsquared

  • /dev/null
  • *
  • Posts: 15
  • Cookies: 0
    • View Profile
IO with external process
« on: 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.

Offline madf0x

  • Knight
  • **
  • Posts: 172
  • Cookies: 50
    • View Profile
Re: IO with external process
« Reply #1 on: November 30, 2014, 06:49:02 pm »
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.

Offline hppd

  • Knight
  • **
  • Posts: 163
  • Cookies: 7
    • View Profile
Re: IO with external process
« Reply #2 on: November 30, 2014, 09:36:57 pm »
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