I'm currently working on a script to notify a user when their password will expire. The prompt appears, but no matter what button I press, it results to the same outcome, "Change Later was chosen". Any ideas?
#!/bin/bash
button=$(osascript -e 'tell application "System Events" to display dialog "Change password now or later?" buttons {"Change Later", "Change Now"} default button 1 with title "Password Update Required" with icon caution')
if [[ $button = "Change Now" ]]; then
open /System/Library/PreferencePanes/Accounts.prefPane
echo "Opening Preferences"
else
echo "Change Later was chosen"
exit 0
fi