Write an login script on Ubuntu [on hold]











up vote
-7
down vote

favorite
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









New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru 15 hours ago


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
    yesterday










  • echo password wrong
    – Mous
    yesterday










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    yesterday








  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    yesterday















up vote
-7
down vote

favorite
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









New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru 15 hours ago


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
    yesterday










  • echo password wrong
    – Mous
    yesterday










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    yesterday








  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    yesterday













up vote
-7
down vote

favorite
1









up vote
-7
down vote

favorite
1






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









New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











 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









New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

38.7k1479128




38.7k1479128






New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Mous

12




12




New contributor




Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru 15 hours ago


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.






put on hold as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru 15 hours ago


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
    yesterday










  • echo password wrong
    – Mous
    yesterday










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    yesterday








  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    yesterday


















  • What if username=="admin" and password=="hello"?
    – PerlDuck
    yesterday










  • echo password wrong
    – Mous
    yesterday










  • and if username=="hello" and password=="admin" (for example) echo username non available
    – Mous
    yesterday








  • 1




    1. Accepting user input. 2. If Statements.
    – Haxiel
    yesterday
















What if username=="admin" and password=="hello"?
– PerlDuck
yesterday




What if username=="admin" and password=="hello"?
– PerlDuck
yesterday












echo password wrong
– Mous
yesterday




echo password wrong
– Mous
yesterday












and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
yesterday






and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
yesterday






1




1




1. Accepting user input. 2. If Statements.
– Haxiel
yesterday




1. Accepting user input. 2. If Statements.
– Haxiel
yesterday










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










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
    yesterday


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










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
    yesterday















up vote
0
down vote



accepted










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
    yesterday













up vote
0
down vote



accepted







up vote
0
down vote



accepted






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 yesterday

























answered yesterday









PerlDuck

1236




1236












  • Thank you so much
    – Mous
    yesterday


















  • Thank you so much
    – Mous
    yesterday
















Thank you so much
– Mous
yesterday




Thank you so much
– Mous
yesterday



Popular posts from this blog

サソリ

広島県道265号伴広島線

Setup Asymptote in Texstudio