JustinMs66@hotmail.com Posted September 2, 2007 Share Posted September 2, 2007 i have been working on this for like 3 hours now, trying EVERYTHING! i need to be able to make system commands work. ping -c 2 -iphere- >response.txt is the code i need. and in ssh, i execute it, and it works! in the response.txt file, i get a correct response: PING -iphere- (-iphere-) 56(84) bytes of data. 64 bytes from -iphere-: icmp_seq=0 ttl=53 time=21.7 ms 64 bytes from -iphere-: icmp_seq=1 ttl=53 time=21.4 ms --- -iphere- ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms But when i use ANY KIND of php system command execution, it does not work. i have tried the system(), exec(), shell_exec(), passthru(), and popen(). none work. response.txt comes up blank. i have also tried setting the permissions to a variety of things, 777,775,755,644... etc. i have also tried setting the owner permisions to root as well as the username that php file executes on. nothing works and its pissing me off. what pisses me off the most is that a command such as "ls" will work perfectly. but why won't this? Quote Link to comment https://forums.phpfreaks.com/topic/67700-system-ping-command/ Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 Try using the full path to ping. Usually /bin/ping. Quote Link to comment https://forums.phpfreaks.com/topic/67700-system-ping-command/#findComment-340139 Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 3, 2007 Author Share Posted September 3, 2007 i just tried it and it made no difference. good idea though, thanks. again, it works if i execute the same command using ssh, just not with php. Quote Link to comment https://forums.phpfreaks.com/topic/67700-system-ping-command/#findComment-340270 Share on other sites More sharing options...
hvle Posted September 3, 2007 Share Posted September 3, 2007 did you tried capture both stdout and stderr? $cmd = 'ping -c 2 www.yahoo.com > response.txt 2>&1'; $shellOutput = shell_exec($cmd); Quote Link to comment https://forums.phpfreaks.com/topic/67700-system-ping-command/#findComment-340273 Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 3, 2007 Author Share Posted September 3, 2007 hmm, that returned "ping: icmp open socket: Operation not permitted" Quote Link to comment https://forums.phpfreaks.com/topic/67700-system-ping-command/#findComment-340283 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.