[thelist] PHP exec()

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


[snip]
<?PHP
$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?
http://ca.php.net/manual/en/ref.exec.php

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?
[/snip]

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

<?php
$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";
        }
    closedir($dh);
    }
}
?>

exec'ing a list may be a little kludgy

HTH!

Jay


More information about the thelist mailing list