note 24176 added to ref.exec
| From: | shanx at shanx dot com | Date: | Thu, 08 Aug 2002 15:49:44 +0000 |
| Subject: | note 24176 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-34534@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/ref.exec.php
http://master.php.net/manage/user-notes.php?action=edit+24176
http://master.php.net/manage/user-notes.php?action=delete+24176
http://master.php.net/manage/user-notes.php?action=reject+24176