note 36766 added to function.exec
| From: | nehle at dragonball-se dot com | Date: | Tue, 21 Oct 2003 18:59:34 +0000 |
| Subject: | note 36766 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59054@lists.php.net to get a copy of this message | ||
Remember that some shell commands in *NIX needs you to set a TERM enviroment. For example:
<?php
exec('top n 1 b i', $top, $error );
echo nl2br(implode("\n",$top));
if ($error){
exec('/usr/bin/top n 1 b 2>&1', $error );
echo "Error: ";
exit($error[0]);
}
?>
This will echo "Error: TERM enviroment variable not set. " To fix it, add TERM=xterm (Or
some other terminal) to the exec-statement, like this
<?php
exec('TERM=xterm /usr/bin/top n 1 b i', $top, $error );
echo nl2br(implode("\n",$top));
if ($error){
exec('TERM=xterm /usr/bin/top n 1 b 2>&1', $error );
echo "Error: ";
exit($error[0]);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36766
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36766&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36766&report=yes
Search -- http://master.php.net/manage/user-notes.php