unset -v input #input="$(/usr/bin/osascript <<-'__HEREDOC__' input="$(/usr/bin/osascript 2>/dev/null <<-'__HEREDOC__' with timeout of 300 seconds tell application "Finder" -- tell application "System Events" activate set Input to display dialog "Please enter your password:" \ with title "Password" \ with icon caution \ default answer "" \ buttons {"Cancel", "OK"} \ default button 2 \ with hidden answer \ giving up after 295 return text returned of Input as string end tell end timeout __HEREDOC__ )" printf "%s\n" "${input}" open -a 'Script Editor' # copy & paste the following snippet into Script Editor with timeout of 300 seconds tell application "Finder" activate set Input to display dialog "Please enter your password:" with title "Password" with icon caution default answer "" buttons {"Cancel", "OK"} default button 2 giving up after 295 with hidden answer return text returned of Input as string end tell end timeout #--------------------------------------- unset -v input name #export name="$(/usr/bin/logname)" export name="$(/usr/bin/whoami)" input="$(/usr/bin/osascript 2>/dev/null <<-__HEREDOC__ with timeout of 300 seconds tell application "Finder" -- tell application "System Events" activate set my_name to "${name}" set my_pass to display dialog "Enter password for " & quoted form of my_name \ with title "Login Window" \ with icon note \ default answer "" \ buttons {"Cancel", "OK"} \ default button 2 \ with hidden answer \ giving up after 295 return text returned of my_pass as string end tell end timeout __HEREDOC__ )" printf "%s\n" "${input}"
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Password request dialog from the command line with AppleScript (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Login window from the comman... in password shell osx mac bash unix window login utf8 UTF-8 pashua dialog
» Testing Terminal RGB color c... in shell osx mac bash unix applescript osascript window terminal color rgb combination
» Testing Terminal RGB color c... in shell osx mac bash unix applescript osascript window terminal color rgb combination
» Testing Terminal RGB color c... in shell osx mac bash unix applescript osascript window terminal color rgb combination
» Testing Terminal RGB color c... in shell osx mac bash unix applescript osascript window terminal color rgb combination
» ws - web search from the com... in shell osx mac search bash unix commandline web
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails