Dalsor
08-31-2002, 05:04 PM
Greetings,
I'm trying to get a quick count of files within a static directory using this tiny snip. The snip always returns 0 for some reason. Not quite sure why. The command, if issued in the shell itself, retuns the actual file count as intended, just not if used in the script. I've tried varying the path statement itself with no success. This is the latest incarnation of the failed attempts. Any advice?
<?php
$dir = shell_exec("ls -la '/path/to/my/files/*'|wc -l|sed 's/^ *//;'");
?>
Players <?php echo($dir); ?><br>
I'm trying to get a quick count of files within a static directory using this tiny snip. The snip always returns 0 for some reason. Not quite sure why. The command, if issued in the shell itself, retuns the actual file count as intended, just not if used in the script. I've tried varying the path statement itself with no success. This is the latest incarnation of the failed attempts. Any advice?
<?php
$dir = shell_exec("ls -la '/path/to/my/files/*'|wc -l|sed 's/^ *//;'");
?>
Players <?php echo($dir); ?><br>