【发布时间】:2011-10-10 13:30:14
【问题描述】:
我的 Applescript 和 Python 脚本在当前工作目录中。 现在我需要使用 shell 命令从 applescript 以管理员权限调用名为 test.py 的 Python 脚本。
Applescript 中的这段代码给出了密码
tell application "Finder" to get folder of (path to me) as Unicode text
set presentDir to POSIX path of result
Applescript 中的这段代码手动从 Applescript 调用 python 脚本
do shell script "/Users/mymac/Documents/'Microsoft User Data'/test.py"
如何将 presentDir 与管理员权限一起添加到该命令中?
编辑和更新:
set py to "test.py "
set calldir to workingDir & py
do shell script calldir
报错
error "sh: /Users/mymac/Documents/Microsoft: No such file or directory" number 127
但是 显示对话框 calldir 显示
/Users/mymac/Documents/Microsoft User Data/test.py
原因:
由于空格,它在 shell 脚本命令中的“Microsoft”一词之后被分解。
【问题讨论】:
标签: python macos shell applescript