<?php

   chdir('/home/abu-jeib/temp');
  
  // Using exec
  echo "<h1>Using exec:</h1>\n";
  exec('ls -l', $list); // or ls -la // For Unix 
  // exec('dir', $list); // For Windows
  echo "<pre>";  
  foreach ($list as $val) 
     echo "$val\n";
  echo "</pre><p>";

   // Using passthru   
   echo "<h1>Using passthru</h1>\n";
   echo '<pre>';  
   passthru('ls -l'); // Unix
   // passthru('dir'); // Windows

   echo '</pre><p>'; 

   // Using system
   echo "<h1>Using system</h1>\n";
   echo '<pre>';
   system('ls -l'); // Unix
   
   // system('dir'); // Windows
   echo '</pre><p>';

   // Using backticks
   echo "<h1>Using backticks</h1>\n";
   echo '<pre>';
   $list = `ls -l`; // Unix
   // $list = `dir`; // Windows
   echo $list;
   echo '</pre>';

   // chown($file,"abu-jeib"); // U can do that but doesn't work sometimes
   // system("chown -r abu-jeib:users $file"); // U can do that, but sometimes does not work
  // copy($file,$new_file); // Works, owner still as original
  // rename($file,$newname); // Works
  // chgrp($file,users); // U can do that, but sometimes does not work
  //  chmod($file,0644); // Works
  // unlink($file); // Works (deletes the file)
  // system("rm $file"); // For Unix
  // system("del $file"); // For Windows
?>

