Pass special characters


I’m attempting to have users be prompted for their passwords and then pass that variable to a unix script and if they use specific characters, the unix script fails. I’m wondering if there is a way to pass the quoted form of the user input to the unix script. Right now, the line that prompts them for their password is this:

userPass=“$(osascript -e 'Tell application “System Events” to display dialog “Please enter your password:” default answer ‘’” with title “Login Password with text button [“Ok”} default button with hidden answer’ -e ‘text returned of result’)”

Thank you for any help!



I’m not particularly au fait with Unix scripts, but can say in this case that you need to get the AppleScript display dialog syntax right!

If you want to put the quoted form of the entered password into userPass, this works in Terminal:

But I don’t know how you’d proceed from there. Whether or not you actually want the quoted form of the input probably depends on how the variable’s to be used in the rest of the Unix script.