FreeBSD Execution System command
FreeBSD Execution System command
function Do_command ($commandName, $args)
{
$buffer = "";
if (false = = = ($command = Find_command ($commandName))) return false;
if ($fp = @popen ("$command $args", ' R '))
{
while (! @feof ($FP))
{
$buffer. = @fgets ($fp, 4096);
}
Return trim ($buffer);
}
return false;
}
Determining the execution file location FreeBSD
function Find_command ($commandName)
{
$path = Array ('/bin ', '/sbin ', '/usr/bin ', '/usr/sbin ', '/usr/local/bin ', '/usr/local/sbin ');
foreach ($path as $p)
{
if (@is_executable ("$p/$commandName") return "$p/$commandName";
}
return false;
}
Calling methods
echo Do_command (' Sysctl ', "-N Hw.model");
?>
http://www.bkjia.com/PHPjc/444944.html www.bkjia.com true http://www.bkjia.com/PHPjc/444944.html techarticle FreeBSD Execution System command FreeBSD Execution System command function Do_command ($commandName, $args) {$buffer =; if (false = = = ($command = Find_co Mmand ($commandName))) return false; If ...