[thelist] PHP exec()

Jay Blanchard jay.blanchard at niicommunications.com
Wed Jul 2 06:59:42 CDT 2003

$base = "/home/emmajane/pictures";
$jhead = "/bin/ls '$base'";
$exif = exec($jhead . "&> error ", $output, $status);
print $exif;
// nothing prints
// $output is an empty array
// $status is "1"

When I call it up in a web browser nothing prints to the page, and no
error file is created. Am I missing something totally obvious?

safe mode is OFF, it's a linux system, PHP is an apache module. None of
these things seem to be a problem according to teh exec reference page
above. Am I missing something else?

You could use opendir() and readdir() here is an example form PHP.net

$dir = "/home/emmajane/pictures/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            print "filename: $file : filetype: " . filetype($dir .
$file) . "\n";

exec'ing a list may be a little kludgy



More information about the thelist mailing list