Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
Whenever I ping an address through PHP (the exec command) and when it's hte second time or more since I've done the same command, I get something like this.
Code:
round-trip min/avg/max/stddev = 3.917/3.917/3.917/0.000 ms

Which is NOT what I want. Any suggestions?

or comments. There must be something I'm missing.

EDIT:
Ooh! It's not just giving me the above line, but instead exec is giving back just the last line.

Code:
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 79.492/80.872/82.678/1.335 ms

Any idea on how to stop this?
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
That looks like what you get in Terminal...

Code:
Last login: Sun Aug 27 11:56:05 on ttyp1
Welcome to Darwin!
Vigor14:~ Matthew$ ping -c 2 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=255 time=0.592 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=0.646 ms

--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.592/0.619/0.646/0.027 ms
Vigor14:~ Matthew$ ping -c 2 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=255 time=0.644 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=0.534 ms

--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.534/0.589/0.644/0.055 ms
Vigor14:~ Matthew$

The -c 2 limit's it to sending 2 pings
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
sorry.

What I actually want it is all the text from the exec command being able to be stored in a variable.
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
bobber205 said:
sorry.

What I actually want it is all the text from the exec command being able to be stored in a variable.

Oh. Can you post the exact code that you're trying to use? Also, try using system() instead of exec(). This works on a server that I'm using at the moment:

Code:
[atmeweb@boxwood bin]$ cat test.php
<?php
echo(system("nslookup google.com"));
?>

[atmeweb@boxwood bin]$ php-cli test.php
Server:         64.29.16.113
Address:        64.29.16.113#53

Non-authoritative answer:
Name:   google.com
Address: 72.14.207.99
Name:   google.com
Address: 64.233.167.99
Name:   google.com
Address: 64.233.187.99

You can also pass an array into exec to get lines of output stored in an array.
http://us2.php.net/function.exec
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.