shell_exec not returning output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

shell_exec not returning output

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: shell_exec not returning output

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: shell_exec not returning output

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply