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..
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.
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 b "$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
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 b "$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
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
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
For that level of control, which you can’t get with osascript, you may want to investigate something like Nudge.
you want to use swift dialog.. https://github.com/bartreardon/swiftDialog
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.