phpcross-process

PHP - Accessing and sending data to process


I've been programming a small client-server-application and now I want to show the output of the server-process in a small server-webpage. Everytime, you press a key in the server-console, the current state is output. Assuming, the server is running and I want to show the current state of the server, how would you implement this in PHP?

My thoughts were to get the process and then send a key input. How could you implement this in PHP? The server is running on debian 6 with Apache and PHP 5.4.

Thanks in advance


Solution

  • Depend on how simple you want to go:

  • the simplest would be to just simulate a get call. for example, the client calls fopen('http://server.example.com/status.php?server=myserver&stats=uptime'); and at the server level, look at $_GET['server'] and $_GET['uptime'] . you can use that method and add authentication either by passing credentials as a variable. The output can be either plain html or json encoded
  • use xml rpc or soap