Find the answer to your Linux question:
Results 1 to 2 of 2
Can anyone help me with a bash shell login script? Its for my unix class and we need to make a script that allows the users we create to login ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    3

    Bash shell login script

    Can anyone help me with a bash shell login script? Its for my unix class and we need to make a script that allows the users we create to login on a screen and put their user name and password on it. Then from that screen it goes to a menu screen IF they put the right login/password combination.

    Heres what i have so far.
    Code:
    tput cup $1 $2
    tput clear
    bold=`tput smso`
    offbold=`tput rmso`
    echo $bold
    tput cup 10 20; echo "User ID:"
    tput cup 12 20; echo "Password:"
    echo $offbold
    tput cup 10 41; read userid
    tput cup 12 41; read password
    while [ "$userid" != "/etc/passwd" ]; do
    	echo $bold
    	tput cup 15 35; echo "Incorrect User/Password"
    	echo $offbold
         if	[ "$userid" = "/etc/passwd" ];
    	then
    	clear
    	./companymenu; 
         fi
    done
    But none of it seems to work.

    I'm stumped on what to do about letting it read a file with the users and password on it. Please help me.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    You can use bash's read command to read a line from standard input. Put it in a loop. Then, for that loop, redirect input from the file you want to read.

    For more information on the read command, enter the following at the command line:
    Code:
    help read
    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...