frustphil
September 28th, 2009, 01:24 AM
Out of curiosity, I am studying it. =)
I am having trouble figuring out what's wrong with this script.
#!/bin/bash
#This a script that identifies a user whether he/she is a normal, system,
#or a root user.
echo -n "Please enter your username: "
read username
if sudo grep -q $username /etc/passwd
then
id=$(sudo id -u $username)
declare -i user_id
user_id=$id
if [ $user_id -ge 500 ]
then
echo "$username, you are a noraml user"
elif [ $user_id -eq 0 ]
echo "$username, you are a root user"
else
echo "$username, you are a system user"
fi
else echo "Sorry, you're not a valid user!"
fi
if I run it, the shell gives me this error:
Please enter your username: frustphil
./identify_user.sh: line 16: syntax error near unexpected token `else'
./identify_user.sh: line 16: ` else '
Any idea what's wrong?
Thanks...=)
I am having trouble figuring out what's wrong with this script.
#!/bin/bash
#This a script that identifies a user whether he/she is a normal, system,
#or a root user.
echo -n "Please enter your username: "
read username
if sudo grep -q $username /etc/passwd
then
id=$(sudo id -u $username)
declare -i user_id
user_id=$id
if [ $user_id -ge 500 ]
then
echo "$username, you are a noraml user"
elif [ $user_id -eq 0 ]
echo "$username, you are a root user"
else
echo "$username, you are a system user"
fi
else echo "Sorry, you're not a valid user!"
fi
if I run it, the shell gives me this error:
Please enter your username: frustphil
./identify_user.sh: line 16: syntax error near unexpected token `else'
./identify_user.sh: line 16: ` else '
Any idea what's wrong?
Thanks...=)