I have a simple shell script that tests whether a password is correct (or not) against an Apple Open Directory (LDAP) server.
What I'd like is simply to lose the gobblygook error message "Authentication for node /LDAPv3/1..." and instead insert my own language such as "password does not match".
Here's what happens now:
bash-3.2# test-password
Enter username you'd like to test password for:
jdoe
Enter Password to test for jdoe
asdasdasd
Authentication for node /LDAPv3/127.0.0.1 failed. (-14090, eDSAuthFailed)
<dscl_cmd> DS Error: -14090 (eDSAuthFailed)
What I'd prefer is:
bash-3.2# test-password
Enter username you'd like to test password for:
jdoe
Enter Password to test for jdoe
asdasdasd
Password matches!
So I just need to know a way so that the std out error message is muffled...
Here's the script:
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
echo
echo Enter username you\'d like to test password for:
read USERNAME
echo
echo Enter Password to test for "$USERNAME"
read PASSWORD
/usr/bin/dscl /LDAPv3/127.0.0.1 auth $USERNAME $PASSWORD
if [ "$?" = "0" ]; then
echo "Password is correct"
exit 0
fi