note 24176 deleted from ref.exec by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 03 Jul 2004 14:59:14 +0000 |
| Subject: | note 24176 deleted from ref.exec by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72472@lists.php.net to get a copy of this message | ||
Note Submitter: shanx@shanx.com
----
Such a long-winded page, this. But none offered anything useful to me. I needed to execute a simple
command, which works at the shell prompt but does not work through the PHP exec. If you do this:
---------- CODE ------------
$result = exec ("ls -ali");
---------- /CODE ------------
and find that your variable contains nothing, don't be surprised. Try this instead:
---------- CODE ------------
exec ("ls -ali", $resultArray);
reset($resultArray);
while (list ($key, $val) = each ($resultArray))
{
$resultLines .= "\n" . trim($val);
}
---------- /CODE ------------
The variable "resultLines" will contain all the results. Hope this helps someone.