PDA

View Full Version : Interacting with other programs



DingoMD
March 26th, 2008, 12:24 PM
I was wondering if there is any way to interact with other programs using C/C++.
Let's say I want to run a program, get some info from its output, and sent it some input when it asks something like "Input x:". Can this be done?

hums07
March 26th, 2008, 01:02 PM
I was wondering if there is any way to interact with other programs using C/C++.
Let's say I want to run a program, get some info from its output, and sent it some input when it asks something like "Input x:". Can this be done?

Interesting question. I am new to programming in linux and wish to know that as well. In Windows, there are techniques called DDE and ... (forgot another - been several years ago). I read about signals and slots inside a linux program. How about between programs?

EDIT: It's DDE and DCOM in Win$

EDIT: According to http://wiki.tcl.tk/18445, you can only use pipe in linux... but I've read that Bibus and OpenOffice can communicate somehow. CMIIW.

DingoMD
March 26th, 2008, 05:58 PM
Unfortunately piping is not enough for what i want to do. I need a way to make two programs "chat" with each other. :(
Thanks for the info anyway.

Glich
March 26th, 2008, 06:03 PM
yes, I would like to know how as well. I guess you could do it over tcp....client and server style.

DingoMD
March 26th, 2008, 06:16 PM
Look here:
http://ioi2007.hsin.hr/tasks/day1/aliens.pdf
More specifically at the "Interaction" and "Testing" sections. Unfortunately I don't have that "./connect" program, which seems to do exactly what I want.

Glich
March 26th, 2008, 06:25 PM
take a look at http://en.wikipedia.org/wiki/D-Bus

I don't fully understand it but it looks promising.

ruy_lopez
March 26th, 2008, 06:39 PM
Unix Domain Protocols is one of the standard ways for different programs to communicate. They actually use sockets similar to TCP/UDP, with an almost identical API, but are specifically designed for operating on the same host.

Other ways use FIFOs, Pipes and STREAMS (not to be confused with FILE *fp streams).

All these can be used from C (and, I imagine, C++).

Glich
March 26th, 2008, 07:06 PM
thanks, I need to brush up on my C and C++ I think

nanotube
March 26th, 2008, 07:23 PM
you could also use the actual network protocols to communicate - have the source program open a port on localhost, and the recipient program read data from the port.

DingoMD
March 26th, 2008, 08:09 PM
Just found this:
http://www.gidforums.com/t-3369.html

Haven't tried yet, but seems to be what I want. Thanks everyone for your tips :)

hums07
March 28th, 2008, 12:24 AM
take a look at http://en.wikipedia.org/wiki/D-Bus

I don't fully understand it but it looks promising.

I believe this is it! Thank's for the link.