开发者

Apache, Linux and Remote Commands Like 'Ping'

开发者 https://www.devze.com 2023-04-12 03:15 出处:网络
I need to contact a server (perhaps Apache) running on a Linux box and have it return the following results. I am new to networking, but can write code in Java, PHP and maybe a little C.

I need to contact a server (perhaps Apache) running on a Linux box and have it return the following results. I am new to networking, but can write code in Java, PHP and maybe a little C.

I need to remotely run diagnostic tests from the Linux box on the local area network. Ultimately these tests need to be delivered to a web page on the client side.

I am not sure where to begin on this project and appreciate any suggestions or general strategies. I am familiar with a command written in Java (i.e., Runtime.getRuntime().exec("ping -c 1 " + ip); ), but I don't know if it is necessary to involve Java and I don't know how to startup a Java program on a server and return it to a PHP file. Is it possible to do this without involvi开发者_如何学Pythonng Java? Again any specific or high- level suggestions are appreciated.


Perhaps you are looking for the exec function in PHP?


You can use exec function

-for ping:

//ping.php
<?php
  exec ("/bin/ping -c 5 www.google.com", $response); 
  echo "<pre>" . join("\r\n", $response)."</pre>";
?>

use the php command-line in terminal

$ php ping.php
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号