Need help with Bash scripting using nano editor

p { margin-bottom: 0.08in; } As you can already tell I am a newbie. I took a Microsoft VB2008 a few month back. Now I'm taking Linux + and this course requires me to write scripts. The script executes but, I can't figure out or have not found anything that I can make out on the internet that can answer my questions.

1 I need to make this two statements: if [ "$user_ID" = jcs ] && [ "$password" = 123456 ]
2 If they enter anything other than y they should get message Goodbye
3 Any comments would be appreciated.
4 I would like to add a counter

 #!/bin/bash
 # Date: 09/25/2011
 # Purpose: Authenticate  
 # Creator: JCS
 # Lasted Changed: 09/25/2011
 clear
 echo -n -e "\n\n\nPlease enter you ID:     "
 read user_ID
 clear
 echo -n -e "\n\n\nPlease enter your password     "
 read password
 clear
 *****if [ "$user_ID" = jcs ] && [ "$password" = 123456 ]; then     
 echo -e "\n\n\nYou have been authenticated."
 else
 echo -n -e "\n\n\nThere is a problem with your authentication. Would you like to try again, enter y for yes."
 read answer
 fi
 while [ "$answer" = y ];
 do
 echo -e "\n\n\nPlease enter you ID:     "
 read user_ID
 clear
 echo -e "Please enter your password     "
 read password
 clear
 if [ "$user_ID" = jcs ] && [ "$password" = 123456 ]; then
    echo -e "You have been authenticated."
 else
 ***echo -e "There is a problem with your authentication. Would you like to try again. Enter y for yes"
 read entry
 fi
 done
#!/bin/bash
display()
{
  clear
  if [ -z "$choice" ] || [ "$choice" == "Y" ]
  then
    echo -e "Please enter your ID : \c"
    read user_id
    echo -e "Please enter the password : \c"
    read passwd
  else
    exit 0
  fi
}
while true
do
  display
  if [ "$user_id" == "jcs" ] && [ "$passwd" == "123" ]
  then
    echo -e "You have been successfully authenticated!"
    exit 0
  else
    echo -e "Authentication failed!"
    echo -e "Do you want to retry ? (Y or N) : \c"
    read choice
    display
  fi
done

You can beautify the display part.
--ahamed

1 Like

Thank you ahamed101, it worked great.:slight_smile: Where can I get more information on the use of the option -z and
[ -z "$choice" ]
display()
{}
I would like to learn more about this functions.
again a million thanks.:slight_smile:

Thank you it worked.

You are welcome!

For scripting, check this
For test operators, check this

--ahamed