Write an login script on Ubuntu [on hold]
up vote
-7
down vote
favorite
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
New contributor
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.
add a comment |
up vote
-7
down vote
favorite
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
New contributor
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 ifusername=="admin"
andpassword=="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
add a comment |
up vote
-7
down vote
favorite
up vote
-7
down vote
favorite
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
New contributor
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
New contributor
New contributor
edited yesterday
Rui F Ribeiro
38.7k1479128
38.7k1479128
New contributor
asked yesterday
Mous
12
12
New contributor
New contributor
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 ifusername=="admin"
andpassword=="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
add a comment |
What ifusername=="admin"
andpassword=="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
add a comment |
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.
Thank you so much
– Mous
yesterday
add a comment |
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.
Thank you so much
– Mous
yesterday
add a comment |
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.
Thank you so much
– Mous
yesterday
add a comment |
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.
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 yesterday
answered yesterday
PerlDuck
1236
1236
Thank you so much
– Mous
yesterday
add a comment |
Thank you so much
– Mous
yesterday
Thank you so much
– Mous
yesterday
Thank you so much
– Mous
yesterday
add a comment |
What if
username=="admin"
andpassword=="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