How to validate login from Bash script
Hello,
I'm new to bash scripting, I have a need to write a script which will take user name and password as input validate the inputs and check whether the username/password combination can really login to the system and if authentication is successful then it has to run a set of other commands roughly about 200 different scripts but if authentication fails then it has ask for correct user name and password again and do the above steps again. If some one can help me with It would be very much helpful. Thanks, Ravi |
Could you explain the "actual" end goal (i.e. what you are actually trying to achieve)? It sounds like you're trying to reinvent the wheel, and you actually want the user to ssh into the system, or something like that.
|
this will be done by the system automatically, just execute su - <username>. It will ask for pw and based on ~/.profile or ~/.bashrc can execute some programs...
|
Hi Snark,
I have a load file which has about 200 commandline entries asking for user name and password, I figured out a way to input user name and password to those script file but instead of asking 200 times I want the user to enter username and password only once. The catch is we have different servers and user authentication is done via ldap, and I don't have access to do an ldap. So instead I want to my script to check whether the given combo of username and password works in the given system. If yes I would take those inputs to run my load file and execute if the authentication fails then I want the script to echo error and ask for valid user name/password combo. A simple conditional statement is what I'm looking for. Any way thanks for the response. |
Right... I'm still not 100% convinced this is the best way to do it, but meh, this should work, and it's not immediately obvious you're doing something silly:
Code:
#!/usr/bin/env bash Hope this helps, |
Hi Snark,
It works. Thanks a ton. |
All times are GMT -5. The time now is 09:14 AM. |