Re: help executing shell commands
| From: | George Whiffen | Date: | Tue, 06 May 2003 12:36:55 +0000 |
| Subject: | Re: help executing shell commands | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146507@lists.php.net to get a copy of this message | ||
Ferando,
Sounds like what you want is readdir(),
http://www.php.net/manual/en/function.readdir.php
The advantages of readdir() over exec('ls ') are speed, security (no possibility of an accidental/deliberate exec("ls $path") with $path set to
rm -rf \; and, by far the least important advantage, cross-platform portability.
George
Fernando Serto wrote:
hi folks, I was trying to figure out how to describe my problem, but I couldn't, so, I decided to show "In Examples Given".
I'm doing this:
<?php
$test = ls /root/;
echo "<pre>add something here => $test</pre>";
?>
and the output:
add something here => amanda-2.4.4.tar.gz
anaconda-ks.cfg
bcrypt
BestCrypt-1.2-2.src.rpm
BestCrypt-1.2-2.tar.gz
cfs-1.3.3bf-11.src.rpm
cfs.1.4.0.beta2.tar.gz
cryptoapi-0.1.0
how can I have an output like this:
add something here => amanda-2.4.4.tar.gz
add something here => anaconda-ks.cfg
add something here => bcrypt
add something here => BestCrypt-1.2-2.src.rpm
add something here => BestCrypt-1.2-2.tar.gz
add something here => cfs-1.3.3bf-11.src.rpm
add something here => cfs.1.4.0.beta2.tar.gz
add something here => cryptoapi-0.1.0
Thanks in advance!
Regards,
Fernando