Write an login script on Ubuntu [closed]
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
closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 '18 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.
add a comment |
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
closed as unclear what you're asking by Christopher, Rui F Ribeiro, G-Man, GAD3R, muru Dec 19 '18 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 ifusername=="admin"andpassword=="hello"?
– PerlDuck
Dec 18 '18 at 18:46
echo password wrong
– Mous
Dec 18 '18 at 18:50
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
1
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58
add a comment |
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
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
linux shell-script ubuntu scripting rsyslog
edited Dec 18 '18 at 18:58
Rui F Ribeiro
39k1479129
39k1479129
asked Dec 18 '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 '18 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 '18 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 ifusername=="admin"andpassword=="hello"?
– PerlDuck
Dec 18 '18 at 18:46
echo password wrong
– Mous
Dec 18 '18 at 18:50
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
1
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58
add a comment |
What ifusername=="admin"andpassword=="hello"?
– PerlDuck
Dec 18 '18 at 18:46
echo password wrong
– Mous
Dec 18 '18 at 18:50
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
1
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58
What if
username=="admin" and password=="hello"?– PerlDuck
Dec 18 '18 at 18:46
What if
username=="admin" and password=="hello"?– PerlDuck
Dec 18 '18 at 18:46
echo password wrong
– Mous
Dec 18 '18 at 18:50
echo password wrong
– Mous
Dec 18 '18 at 18:50
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
1
1
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58
add a comment |
1 Answer
1
active
oldest
votes
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.
Thank you so much
– Mous
Dec 18 '18 at 19:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Thank you so much
– Mous
Dec 18 '18 at 19:08
add a comment |
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.
Thank you so much
– Mous
Dec 18 '18 at 19:08
add a comment |
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.
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.
edited Dec 18 '18 at 19:09
answered Dec 18 '18 at 19:05
PerlDuck
1236
1236
Thank you so much
– Mous
Dec 18 '18 at 19:08
add a comment |
Thank you so much
– Mous
Dec 18 '18 at 19:08
Thank you so much
– Mous
Dec 18 '18 at 19:08
Thank you so much
– Mous
Dec 18 '18 at 19:08
add a comment |
What if
username=="admin"andpassword=="hello"?– PerlDuck
Dec 18 '18 at 18:46
echo password wrong
– Mous
Dec 18 '18 at 18:50
and if username=="hello" and password=="admin" (for example) echo username non available
– Mous
Dec 18 '18 at 18:52
1
1. Accepting user input. 2. If Statements.
– Haxiel
Dec 18 '18 at 18:58