You are not logged in.
Hello!
Thank you for all the answers! It ended up like this. The reason i run multiple scripts is because I am a real beginner and don't want 2000+ lines of code. That's just me. Sure, it would be lovely if a could get it all in one script but wont that be a heck lot of work putting it all together?
if
[ $UID -ne 0 ]; then
echo "************ WARNING **************"
echo "YOU NEED TO BE ROOT TO USE THIS !"
echo "You are just a ordinary user (but mom loves you just the same)." # =) =) =)
echo "************ WARNING **************"
exit
clear
But now to my second problem with the users and groups menus. The problem is that I need to check if a user already exist and I think I have done it right but apparently not
OPTIONS="Add-user Delete-user Edit-user Return"
select opt in $OPTIONS; do
if [ "$opt" = "Add-user" ]; then
echo ""
echo "Please select a username for the new account: "
read username
echo "And now the password: "
stty_orig=`stty -g`
stty -echo
read password
stty $stty_orig
grepit='grep -o -m 1 ^$username /etc/passwd'
$grepit
if
[ "$grepit" = "$username" ]; then
echo "This username already exist, please try again"
else
echo "Select a primary group for the account (the group must exist): "
read group
echo "Are you sure you want to add this user? (y/n)"
read yorn
fi
if [ "$yorn" = "y" ]; then
useradd -g $group -p $password $username
echo "$username added with the primary group $group."
echo ""
fi
/ Best regards, Afnaf
Last edited by Afnaf (2009-10-10 16:08:36)
Offline
You know there's an easier (and much shorter) to handle the root check right?
[ $(whoami) = 'root' ]
Or are you thinking of something else?
Last edited by scragar (2009-10-06 04:01:39)
Offline
You're sleeping for 10 seconds, making the user wait 10 seconds for something that should be instant..?
You can't do what you're asking, because each script runs in it's own process, and the variables won't be shared between processes. Is there a reason you're using separate scripts instead of functions within one script?
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Offline
Not what I was thinking, but it'd work.
[ $UID -ne 0 ] && exit 1
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Ghost1227 wrote:Not what I was thinking, but it'd work.
[ $UID -ne 0 ] && exit 1
[ `id -u` == 0 ] || exit `id -u`
Last edited by lolilolicon (2009-10-06 05:47:44)
This silver ladybug at line 28...
Offline