Applescript - 提交包含&符号的密码

时间:2018-01-11 00:52:00

标签: applescript

我一直在尝试创建一个Applescript,它将在帐户上启用High Sierra安全令牌(通过Jamf的自助服务)。它工作正常,直到尝试密码中包含密码字符的人。使用'运行shell脚本'是否需要特定的语法?在一个AppleScript中,以避免变量中包含的&符问题?感谢您对此提供任何帮助。

这是苹果脚本:

#!/usr/bin/osascript
set the_folder to (path to users folder)
tell application "Finder"
set foldernames to name of every folder of the_folder
end tell
set theChosenOne to choose from list foldernames with prompt "Select user to receive secure token"
display dialog "Password for " & theChosenOne default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue" with hidden answer
set thePassword to text returned of the result
do shell script "sysadminctl interactive -secureTokenOn " & theChosenOne & " -password " & thePassword
set theVerification to do shell script "sysadminctl interactive -secureTokenStatus " & theChosenOne & " 2>&1 | awk -F']' '{print $2}'"
display dialog theVerification
return

1 个答案:

答案 0 :(得分:0)

为了在AppleScript中转义&符号,您需要用quoted form包装字符串(或变量)。

在你的情况下:

set thePassword to quoted form of text returned of the result