Making a PHP script interact with another process

jdport

Senior member
Oct 20, 2004
710
0
71

I'm trying to write a PHP script that will basically send input to a process, and receive back its output. Specifically, I want write a script to interact with gnuchess in engine mode... where I send a move, and receive back the computer's move (or a message that my move was not legal). How would I go about doing this in PHP, any suggestions or pointers?

Thanks!
 

jdport

Senior member
Oct 20, 2004
710
0
71
I just looked at that command... I can see how that would work to execute a command and return the output but would that work for a send/recieve/send/receive/send receive... continuous interaction with another process ?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,815
75
Ah, you need to maintain a session.

This also means gnuchess needs to be associated with each session. I'm not sure how you were planning to interface with gnuchess in the first place, but if you can find some documentation on it, the ICS protocol might be helpful. I.e. you could have the PHP create a new connection with ICS.
 

jdport

Senior member
Oct 20, 2004
710
0
71
I"m not sure how I was planning on it either, thus the question :)

I was hoping to be able to initiate a pipe of some sort to gnuchess (running in engine mode with the -x flag) and send a string, then wait for the response ... then send another string... wait for response, etc...

Maybe i can't do that with PHP... was hoping i could.