Write an login script on Ubuntu [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












-7














 The idea is that I need to write the username and the password and the script tell me who I am.



  • if:

    username: admin pass: admin the script echo: "you are an admin"

  • if:

    username: user pass: user the script echo: "you are a user"

  • if:

    username: anonymous pass: anonymous the script echo: "you are anonymous"

  • if

    username=="admin" and password=="hello"
    echo password wrong

  • if

    username=="hello" and password=="admin" (for example) echo username non available









share|improve this question















closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 at 14:00


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • What if username=="admin" and password=="hello"?
    – PerlDuck
    Dec 18 at 18:46










  • echo password wrong
    – Mous
    Dec 18 at 18:50










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    Dec 18 at 18:52







  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    Dec 18 at 18:58















-7














 The idea is that I need to write the username and the password and the script tell me who I am.



  • if:

    username: admin pass: admin the script echo: "you are an admin"

  • if:

    username: user pass: user the script echo: "you are a user"

  • if:

    username: anonymous pass: anonymous the script echo: "you are anonymous"

  • if

    username=="admin" and password=="hello"
    echo password wrong

  • if

    username=="hello" and password=="admin" (for example) echo username non available









share|improve this question















closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 at 14:00


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • What if username=="admin" and password=="hello"?
    – PerlDuck
    Dec 18 at 18:46










  • echo password wrong
    – Mous
    Dec 18 at 18:50










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    Dec 18 at 18:52







  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    Dec 18 at 18:58













-7












-7








-7


1





 The idea is that I need to write the username and the password and the script tell me who I am.



  • if:

    username: admin pass: admin the script echo: "you are an admin"

  • if:

    username: user pass: user the script echo: "you are a user"

  • if:

    username: anonymous pass: anonymous the script echo: "you are anonymous"

  • if

    username=="admin" and password=="hello"
    echo password wrong

  • if

    username=="hello" and password=="admin" (for example) echo username non available









share|improve this question















 The idea is that I need to write the username and the password and the script tell me who I am.



  • if:

    username: admin pass: admin the script echo: "you are an admin"

  • if:

    username: user pass: user the script echo: "you are a user"

  • if:

    username: anonymous pass: anonymous the script echo: "you are anonymous"

  • if

    username=="admin" and password=="hello"
    echo password wrong

  • if

    username=="hello" and password=="admin" (for example) echo username non available






linux shell-script ubuntu scripting rsyslog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 18 at 18:58









Rui F Ribeiro

39k1479129




39k1479129










asked Dec 18 at 18:40









Mous

12




12




closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 at 14:00


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 at 14:00


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • What if username=="admin" and password=="hello"?
    – PerlDuck
    Dec 18 at 18:46










  • echo password wrong
    – Mous
    Dec 18 at 18:50










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    Dec 18 at 18:52







  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    Dec 18 at 18:58
















  • What if username=="admin" and password=="hello"?
    – PerlDuck
    Dec 18 at 18:46










  • echo password wrong
    – Mous
    Dec 18 at 18:50










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    Dec 18 at 18:52







  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    Dec 18 at 18:58















What if username=="admin" and password=="hello"?
– PerlDuck
Dec 18 at 18:46




What if username=="admin" and password=="hello"?
– PerlDuck
Dec 18 at 18:46












echo password wrong
– Mous
Dec 18 at 18:50




echo password wrong
– Mous
Dec 18 at 18:50












and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 at 18:52





and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 at 18:52





1




1




1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 at 18:58




1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 at 18:58










1 Answer
1






active

oldest

votes


















0














I expect you do not want to write a real login script but rather
want to play a bit with scripting. The following script will do what
you ask …



#!/usr/bin/env bash

read -p "username: " username
read -p "password: " password

case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac


… but it has some flaws:



  • It shows the password in cleartext while the user is typing.
    This is usually NOT what anyone wants.

  • The usernames and passwords must be equal in this case and
    are also hard coded in the script. That means: anyone who
    can execute this script can also look into it and see what
    the expected passwords are.

The script prompts for username and password and stores them in the
variables $username and $password. Then it checks whether the
$username is one of admin, user, or anonymous. If so, it
checks whether the $username and the $password match.






share|improve this answer






















  • Thank you so much
    – Mous
    Dec 18 at 19:08

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I expect you do not want to write a real login script but rather
want to play a bit with scripting. The following script will do what
you ask …



#!/usr/bin/env bash

read -p "username: " username
read -p "password: " password

case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac


… but it has some flaws:



  • It shows the password in cleartext while the user is typing.
    This is usually NOT what anyone wants.

  • The usernames and passwords must be equal in this case and
    are also hard coded in the script. That means: anyone who
    can execute this script can also look into it and see what
    the expected passwords are.

The script prompts for username and password and stores them in the
variables $username and $password. Then it checks whether the
$username is one of admin, user, or anonymous. If so, it
checks whether the $username and the $password match.






share|improve this answer






















  • Thank you so much
    – Mous
    Dec 18 at 19:08















0














I expect you do not want to write a real login script but rather
want to play a bit with scripting. The following script will do what
you ask …



#!/usr/bin/env bash

read -p "username: " username
read -p "password: " password

case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac


… but it has some flaws:



  • It shows the password in cleartext while the user is typing.
    This is usually NOT what anyone wants.

  • The usernames and passwords must be equal in this case and
    are also hard coded in the script. That means: anyone who
    can execute this script can also look into it and see what
    the expected passwords are.

The script prompts for username and password and stores them in the
variables $username and $password. Then it checks whether the
$username is one of admin, user, or anonymous. If so, it
checks whether the $username and the $password match.






share|improve this answer






















  • Thank you so much
    – Mous
    Dec 18 at 19:08













0












0








0






I expect you do not want to write a real login script but rather
want to play a bit with scripting. The following script will do what
you ask …



#!/usr/bin/env bash

read -p "username: " username
read -p "password: " password

case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac


… but it has some flaws:



  • It shows the password in cleartext while the user is typing.
    This is usually NOT what anyone wants.

  • The usernames and passwords must be equal in this case and
    are also hard coded in the script. That means: anyone who
    can execute this script can also look into it and see what
    the expected passwords are.

The script prompts for username and password and stores them in the
variables $username and $password. Then it checks whether the
$username is one of admin, user, or anonymous. If so, it
checks whether the $username and the $password match.






share|improve this answer














I expect you do not want to write a real login script but rather
want to play a bit with scripting. The following script will do what
you ask …



#!/usr/bin/env bash

read -p "username: " username
read -p "password: " password

case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac


… but it has some flaws:



  • It shows the password in cleartext while the user is typing.
    This is usually NOT what anyone wants.

  • The usernames and passwords must be equal in this case and
    are also hard coded in the script. That means: anyone who
    can execute this script can also look into it and see what
    the expected passwords are.

The script prompts for username and password and stores them in the
variables $username and $password. Then it checks whether the
$username is one of admin, user, or anonymous. If so, it
checks whether the $username and the $password match.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 18 at 19:09

























answered Dec 18 at 19:05









PerlDuck

1236




1236











  • Thank you so much
    – Mous
    Dec 18 at 19:08
















  • Thank you so much
    – Mous
    Dec 18 at 19:08















Thank you so much
– Mous
Dec 18 at 19:08




Thank you so much
– Mous
Dec 18 at 19:08


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay