#!/bin/bash #######This script makes sure that the user name that is entered ############### ###### is valid and if NOT it keeps prompting for the user name ############### ############################################################################################# # CREATED BY FAHAD SAEED and FAHAD ALI ARSHAD string="" cp /home/script/database /home/script/database1 while test $string="" do mylogin="" #prompts the user for user name and enters this in file named login zenity --entry --title="LAB 1" --text="Enter the USERNAME">/home/script/login # thIS will make the database1 to appear in the database2 with every data one line each sed 's/[ ][ ]*/\ /g' /home/script/database1>/home/script/database2 #now comparing the login entered with the logins in the database grep -f /home/script/login /home/script/database2>/home/script/test1 #if the login is in the database then test1 should not be empty string=`cat /home/script/test1` echo $string # if the $string is empty it means that the login name entered is not in the database #else it exits this loop export $string if test "$string" = "" then zenity --error --text="Incorrect user name or password" #echo incorrect login name or password else exit 0 fi # end of while looop done