Skip to main content
Solved

How can i "TEST" as password ?

  • December 12, 2018
  • 1 reply
  • 5 views

Forum|alt.badge.img+8

I have a script I use to change passwords on my MAC's, what I'd really like to do is have the script check the password to see if it is different before attempting to change it.

Best answer by DBrowning

This should do what you are looking for:

#!/bin/sh
PASSWORDCHECK=$(/usr/bin/dscl /Local/Default -authonly $USERNAME $PASSWORD)
if [ "$PASSWORDCHECK" == "" ]; then
echo "Password is correct"
else
echo "Lets reset"
fi

1 reply

DBrowning
Forum|alt.badge.img+25
  • Esteemed Contributor
  • Answer
  • December 12, 2018

This should do what you are looking for:

#!/bin/sh
PASSWORDCHECK=$(/usr/bin/dscl /Local/Default -authonly $USERNAME $PASSWORD)
if [ "$PASSWORDCHECK" == "" ]; then
echo "Password is correct"
else
echo "Lets reset"
fi