Hi
I am writing a script to adduser,group and create a folder called public_html with the permissions required and i am deleting the user.For this i am trying write a script with options selection for adding user,deleting user and exit.The script as follows.when i try to run these two scripts it is working fine.I am trying this script in debian.When i combine with the menu script i am getting syntax error
complete.csh: line 2: echo======================
==========
==========
==========
==========
=: command not found
Welcome to User Management \!\!
complete.csh: line 6: echo======================
==========
==========
==========
==========
=: command not found
complete.csh: line 20: syntax error near unexpected token `newline'
complete.csh: line 20: `set num = $ <'
Script
#!/bin/bash
echo"=====================
==========
==========
==========
==========
=="
echo ""
echo " Welcome to User Management \!\! "
echo ""
echo"=====================
==========
==========
==========
==========
=="
echo ""
while (1)
echo ""
echo ""
echo "Please select an option from the following menu."
echo ""
echo "1. Add New Account"
echo "2. Remove existing account"
echo "3. Exit Menu"
echo ""
echo -n "Enter selection >> "
set num = $ <
echo ""
echo ""
switch ($num)
case 1:
echo "User to add:"; read UAuser;
groupadd $UAuser
useradd -g $UAuser -m -d /home/www/$UAuser -s /bin/sh $UAuser
mkdir /home/www/$UAuser/public_h
tml
chown $UAuser /home/www/$UAuser -R
chgrp $UAuser /home/www/$UAuser -R
chmod 711 /home/www/$UAuser -R
chmod 755 /home/www/$UAuser/public_h
tml/ -R
passwd $UAuser
echo
echo "User added. "
exit 0
breaksw
case 2:
echo "Enter the UserName:"; read UAuser
userdel -r $UAuser
groupdel -r $UAuser
echo
echo "User deleted Successfully"
exit 0
breaksw
case 3:
exit
endsw
continue
end
Thanks for your help
Start Free Trial