tags:

views:

34

answers:

3

Hi All,

I need to write a piece of code which will invoke a process and dynamically issue commands to the process. For example, I may have to run FTP and then when the process is up, I've to issue ftp commands to this process. I need to do this in C++. I don't have a single clue of where to start.

+1  A: 

Use popen (_popen) function.

Abyx
+1  A: 

It depends on what you mean issue commands to a process.

  1. If you want to feed the started process's stdin, you can do it with the handle of the input stream which will be given to you when you create the process.

  2. If you want to notify the started process about something you could use named Events.

  3. If you want to pass data to the other process you can use shared memory.

This is far from complete, and I am no windows expert, but hopefully this helped a bit.

Armen Tsirunyan
A: 

how about popen() or system()? If they are not suffice for your need then you will need IPC mechanism between the process(which will listen/read over socket/message queue for particular commands and try to execute them and return back the result in certain shared memory/over socket).

Madhava Gaikwad