Running a program with shell_exec() : shell_exec « Utility Function « PHP






Running a program with shell_exec()

 
<?
$df_output = shell_exec('/bin/df -h');
$df_lines = explode("\n", $df_output);

for ($i = 1, $lines = count($df_lines); $i < $lines; $i++) {
    if (trim($df_lines[$i])) {
        $fields = preg_split('/\s+/', $df_lines[$i]);
        print "Filesystem $fields[5] is $fields[4] full.\n";
    }
}
?>
  
  








Related examples in the same category

1.Using the shell_exec() Function