Sean
Sean

Reputation: 1

Having unix code problem?

Im having a problem with my unix code

#!/bin/bash
while : ; do   
echo "SELECT OPTION"   
echo "-------------"   
echo "1- Create username"   
echo "2- Create password"   
echo "3- Delete username"   
echo "4- Exit"   
read -p "enter option 1 2 3 or 4:" option   
case option in      
1) read -p "Enter username:"        
 adduser $REPLY && echo "Username successfully entered"   ;;      
2) passwd && "Password successfully entered" ;;      
3) read -p "Enter user to be deleted: "         
deluser $REPLY && echo "User deleted"  ;;      
4) exit  ;;      
*) continue  ;;   
esac
done

Ok the select option works, but if i type in 1 or 2 as an option to create username or password, its takes me back to the select options again. Whatever i do press it will always show the select option

Can someone help me run this code in unix using bash.

Thank You

Upvotes: 0

Views: 100

Answers (1)

thejh
thejh

Reputation: 45568

Try $option - option gets interpreted as a string.

Upvotes: 4

Related Questions