I have added the following code as root to a users
.bash_profile file so they will be prompted with a menu
and depending on their choice will join another group,
but when the user1 has choosen 1, permission is
denied on the change group command presumably
because it is being executed by a simple user and not
root, it had worked outside the case statement at one stage but not inside and need it to work within
the case statement.
Could you please help find a way round it.
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
# menu
#
clear
echo "-----------------------------------"
echo "Main Menu"
echo "------------------------------------"
echo "[1] Group1"
echo "[2] Group2"
echo "[3] Group3"
echo "[4] Group4"
echo "[5] Exit"
echo
"======================================"
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) gpasswd -a user1 group1;;
2) echo "Group2"; read;;
3) echo "Group3"; read;;
4) echo "Group4"; read;;
5) exit 0;;
*) echo " Bad choice, choose again"; read;;
esac