PHP/Utility Function/shell exec

Материал из Web эксперт
Перейти к: навигация, поиск

Running a program with shell_exec()

   <source lang="html4strict">

<? $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";
   }

} ?>

 </source>
   
  


Using the shell_exec() Function

   <source lang="html4strict">

<?php

    $output = shell_exec("ls");
    echo $output;

?>

 </source>