If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Useradd passing variable from shell script to PHP.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-25-04, 04:51
Junn Junn is offline
Registered User
 
Join Date: Nov 2004
Posts: 1
Lightbulb Useradd passing variable from shell script to PHP.

Hi guys, this is the 1st post and i hope that someone can solve my problem. This is the 1st time i'm touching shell script and have encounter some problems along the way.

DO:
I need to do something like mail system. Ex. (yahoo mail).
I gt User interface to create new user and password.
The thing is i'm using a php script to execute the shell script which contains the useradd function to add a user. I'm working on a mandrake machine.

Problem:
I was unable to adduser. I guess that because i'm not root so i'm not able to adduser. But how do i add the command on the shell script to let it execute as a root?? I'm really a novice of shell script. Or is it some other possible problems?? I have try to figure out myself but maybe i'm too dumb. Please help out.

Thanks

Coding:
#if [ "$(whoami)" != "root" ] ; then
# echo "Error: You must be root to run this command." >&2
# exit 1
#fi

PATH="./bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:"
export PATH

#if [ "$1" = "" ] ; then
# echo "You must key in your username as first argument and password as second argument"
# exit 1
# elif [ "$2" = "" ] ; then
# echo "you must key in your password as second argument"
# exit 1
#fi
User="adduser"
$User $1
echo $1

echo $2 > passwdfile

Pw="passwd" #Creating password
#export $Pw
$Pw --stdin $1 < passwdfile

rm -rf passwdfile





If this question has been ask before, kindly quote the post thanks..

Last edited by Junn; 11-25-04 at 04:59. Reason: forgot to add the coding
Reply With Quote
  #2 (permalink)  
Old 11-26-04, 10:24
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
I would be very careful about running something as root from the web. For example, what do you think would happen if somebody enters "-g 0 user" as a username? Or, better yet, "auser && rm -rf /"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On