I have a CLI.exe developed by mono and want to control it by PHP. My idea is let the CLI keep readline as its input, after this, we can get a PID of this CLI. Next, Let PHP scripts send commands to this CLI as CLI's input via PID(or something else). But I don't know if there's any PHP func can do this or how. Any help is appreciate!
Asked
Active
Viewed 101 times
1 Answers
0
If you want to communicate with the process via STDIN/STDOUT, you'll need to spawn it from PHP using proc_open, which gives you access to these pipes.
To more closely match what you ask, I'd suggest named pipes or unix sockets. If your CLI.exe is the parent, it would use the mkfifo system call to create the named-pipes. PHP has some good documentation here.
Another alternative on *nix platforms is Unix Domain Sockets. Typically these are files named with the .sock extension under the /var/run folder (or subdirs).

Stuart Carnie
- 5,458
- 1
- 29
- 27