note 9607 added to popen
| From: | gege at china dot com | Date: | Tue, 14 Nov 2000 21:37:34 +0000 |
| Subject: | note 9607 added to popen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7695@lists.php.net to get a copy of this message | ||
I use following codes to add a user to system, but it doesn't works! My system is terbolinux
6.0.2 + php 4.0.2 + apache 1.3.12. There is an infomation in httpd/error_log file: standard in must
in a tty. Who can do me a fever how to solve it?
<?
/* add a system user by PHP
in following code, add a user named james, passwd of root is verygood
*/
$sucommand = "su --login root --command";
$useradd = "useradd ";
$rootpasswd = "verygood";
$user = "james";
$user_add = sprintf("%s \"%s %s\"",$sucommand,$useradd,$user);
$fp = @popen($user_add,"w");
@fputs($fp,$rootpasswd);
@pclose($fp);
?>
But when I was under console, I type
su -l root -c "useradd james"
and after I input root's passwd, new user was born...
http://www.php.net/manual/function.popen.php