Page 1 of 1

Need help - Want to send and receive data from external prog

Posted: Thu Jan 19, 2006 5:27 pm
by Mark1Up
Hello,

I'm trying to figure out how I can start an external program (for example RunProgram("cmd.exe") ) and then use stdin and stdout to pass data between the external program and my PB program. (I'm actually trying to use PB to interactively control an SSH terminal session using PuTTY (or Plink) as the external program.)

I have found PB examples that seem pretty straight forward using stdin/stdout when communicating to a PB console but not to an external program. Is there a different way I can start the external program (i.e. with WinAPI) that would allow me to use the stdin/out or is there a way to redirect the stdin/out to communicate with the external program started with RunProgram()?

Thanks in advance for any help on this. (Even some general pointers to best approach would be appreciated) :wink:

Best Regards,
Mark

Posted: Thu Jan 19, 2006 5:30 pm
by El_Choni

Posted: Thu Jan 19, 2006 6:18 pm
by Mark1Up
El_Choni,

Thanks for the quick reply but it looks like the MailSlot feature requires that I add mailslot handling to both the client and server application. In this case I am only programming in PB on one end of the communication, the other application is from a 3rd party and I don't have any control of handling mailslot communications. Is mailslot a standard feature that most applications support by default?

Regards,
Mark

Posted: Thu Jan 19, 2006 6:26 pm
by El_Choni
If the external program is a console program, you can use pipes:

viewtopic.php?t=6544

If it's a GUI program, it depends on the interface, it would be more tricky.

Posted: Thu Jan 19, 2006 6:52 pm
by Mark1Up
The pipes method looks like it might work. Boy, Microsoft sure doesn't make it easy to accomplish something that wouldn't seem to be that difficult.

Thanks again for the quick feedback!