LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-06-2005, 06:25 PM   #1
maneeshsethi
LQ Newbie
 
Registered: Aug 2003
Posts: 25

Rep: Reputation: 15
Run PHP shell_exec as root


Hello

I am trying to get my php script to add a user using the shell_exec function and the shell function "useradd". I have tried this, which works from the shell

echo rootpass |sudo /usr/sbin/useradd -d /home/username -m -p userspassword username

This works from the shell, but doesn't work from the php script. I know basic shell_exec functions work, but this one needs to be executed as root, and I don't know what to do.

How can I fix this? Thanks

-Maneesh
 
Old 03-06-2005, 09:17 PM   #2
t0ny747
LQ Newbie
 
Registered: Mar 2005
Location: Nampa, Idaho
Distribution: Fedora, Gentoox,...
Posts: 7

Rep: Reputation: 0
try
Code:
echo rootpass |sudo "/usr/sbin/useradd -d /home/username -m -p userspassword username"
 
Old 03-06-2005, 09:24 PM   #3
maneeshsethi
LQ Newbie
 
Registered: Aug 2003
Posts: 25

Original Poster
Rep: Reputation: 15
nope, that doesn't work
 
Old 03-06-2005, 09:37 PM   #4
maneeshsethi
LQ Newbie
 
Registered: Aug 2003
Posts: 25

Original Poster
Rep: Reputation: 15
Hrm, now even my shell command won't work. Does anyone have any ideas as how to add a user to your computer from PHP?


-Maneesh
 
Old 03-07-2005, 09:23 AM   #5
maneeshsethi
LQ Newbie
 
Registered: Aug 2003
Posts: 25

Original Poster
Rep: Reputation: 15
bump. Ideas?
 
Old 12-30-2008, 08:25 AM   #6
Beforez
LQ Newbie
 
Registered: Dec 2008
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by maneeshsethi View Post
bump. Ideas?
Yes. Webmin does that, but... Its CGI, not php.

btw, 5-YEAR-EPIC-BUMP
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 10:47 PM
How to run php as root user ??? taqs Programming 2 09-01-2004 06:11 AM
help getting pptp-php-gtk.php to run as root mrtwice Linux - Software 0 11-21-2003 01:49 PM
PHP: what's wrong with this line (shell_exec, find, xargs, grep)? J_Szucs Programming 3 11-19-2003 08:44 PM
Is their a way to run a command as root..or another user.. in php BaerRS Programming 2 04-25-2002 03:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration