I’m trying to script a shell script for a remote location that will add the current user to the _lpadmin group on Mountain Lion. The problem (other than I don’t really know what I’m doing) is that the admin password has an ampersand in it.
tell application "System Events" to set userName to name of current user
-- display dialog userName
set textEntered to display dialog "Enter your admin password:" default answer "" with hidden answer
set adminPW to the text returned of textEntered as string
set sScript to "dseditgroup -o edit -u adminuser -P " & adminPW & " -a " & userName & " -t user _lpadmin" as string
--display dialog sScript as string
do shell script sScript
When i display the script it appears correct, password with an ampersand in it and all. But when I do the script, it errors out, treating the ampersand in the password as a concatenation symbol and therefore throwing the shell script off. I’ve tried it setting adminPW without specifying as string, as well.
How can I get around this (besides changing the password, which is not an option)?
Thanks.
Don