Posted on 05-02-2023 03:42 AM
Posted on 05-02-2023 04:21 AM
where is $user coming from? don't you need switches for -u -P ?
do you want to run dscl in a sub process? your doing a redirect to dev null after the ampersand?
Confused..
Posted on 05-02-2023 09:24 AM
It works as long as it knows what $user is. Not sure if this is the whole script or just a snippet of it, but you need to make sure the $user variable is being populated correctly or the dscl command will always fail.
Posted on 05-02-2023 11:50 AM
Here’s a snippet I use. Instead of allowing five attempts, it’ll repeatedly prompt until either the response is not blank or the dialog is canceled. I’ve also added “with hidden answer” since you’re wanting to capture a password. This will obscure the response.
#!/bin/zsh
while [ "$theText" = "" ]
do
pass=$( /usr/bin/osascript -e "display dialog \"Please, type your Password to start the operation:\" default answer \"\" buttons {\"Cancel\",\"OK\"} default button {\"OK\"} with title \"Test\" with icon POSIX file \"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns\" with hidden answer" 2>&1 )
theText=$( echo "$pass" | /usr/bin/awk -F "text returned:" '{print $2}' )
if [[ $pass == *"User canceled"* ]]; then
exit 1
fi
done
Posted on 05-30-2023 02:28 AM
Hello @talkingmoose ,
This awesome!
However, if prompt remains blank am not forced to fulfill it. I can just drag the popup a way and continue working. Is there a way to force user to type his pwd instantly link in mac software installer ? or make the pop up full screen?
Thanks a lot
Posted on 05-30-2023 07:27 AM
For that level of control, which you can’t get with osascript, you may want to investigate something like Nudge.
Posted on 05-30-2023 07:58 AM
you want to use swift dialog.. https://github.com/bartreardon/swiftDialog