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..