0

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

michaeln
  • 1,032
  • 17
  • 33

1 Answers1

0

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
  • Youn Elan
    • 2,379
    • 3
    • 23
    • 32
    • - That's my main problem. I want to display this data with the information I got from the console. I understood your answer like this: update these states every (e.g.) 5 seconds into a file and display these states in my PHP-page - How would you implement the second one? – michaeln Feb 10 '13 at 16:04
    • not sure what you are trying to do but 2 options: (1) update a file with a cron job (2) execute the command to get that information with backticks. For example, for uptime, use $uptimeResult=`uptime`; – Youn Elan Feb 10 '13 at 16:09
    • not sure why the backticks are removed, it is the character like a quote by slanted on the top left of qwerty keyboards - it executes the command and puts the result in the variable – Youn Elan Feb 10 '13 at 16:14
    • I think we're talking past each other. The process is already running and I want to interact with this running one, not start a new one. But I think you're right, updating an external file would be simpler than digging into the processes. Thanks anyway! – michaeln Feb 10 '13 at 20:44