On 12/27/2009 10:53 PM, robert mena wrote:
I need to develop an interface that will, for example, ping IPs from a
remote server. So the php script will be hosted in a server with ssh access
(key) to the remote server.
I can make it work from the console but when I try
$cmd = "ssh remote-server 'ping -c 4 ip'"
the output is empty.
the same command (with the remote-server and IP changed to the real ones)
works fine from command line.
I've added the key/config in the webserver's user .ssh directory so I am
assuming that that there is something wrong with my setup.
Probably other ways to do it, but this seems to work:
[mich...@archie ~]$ php a.php
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.518 ms
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.518/0.518/0.518/0.000 ms
[mich...@archie ~]$ cat a.php
$stuff = `ssh management 'ping -c 1 192.168.1.1'`;
echo strlen($stuff) . "\n\n$stuff";
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php