Page 1 of 1

shell_exec not returning output

Posted: Wed Sep 15, 2010 11:51 am
by pickle
Hi all,

I'm running a script on an OpenBSD box we have set up as a gateway for 350 students in our residences. Every once in a while (generally about once every 2 or 3 days), we get errors that the ARP table is empty (we use that to get a user's MAC address).

Since this is a gateway for 350 students, it's highly unlikely that the ARP table is actually empty - which leads me to question why, when I call shell_exec("arp -a") that the returned string is empty.

Is there any chance shell_exec() is returning before arp returns, thereby not catching the output generated by the call? I call the command twice in rapid succession and when the error happens, both calls are affected by it. Failing that <not really a PHP question> do you know how/if it's possible the ARP table is empty?</not>

Thanks.

Re: shell_exec not returning output

Posted: Wed Sep 15, 2010 4:53 pm
by AbraCadaver
ARP entries / cache expire at some point. I think FreeBSD was every 60 seconds but I don't remember if it is per entry or for the entire cache. I thought OpenBSD was 20 minutes, but there is a kernel flag that is set that ARP uses to determine this.

Re: shell_exec not returning output

Posted: Wed Sep 15, 2010 5:00 pm
by pickle
That expiry is on specific entries, not the whole cache.

Since I posted this, we discovered that arp isn't returning nothing, it's exiting with an exit code of -1. Unfortunately, it appears no one has ever encountered this, nor is there any documentation to explain why an arp lookup might be failing.