【问题标题】:Apple script getting Syntax error - Error: Expected end of line, etc. but found “"”Apple 脚本出现语法错误 - 错误:预期行尾等,但发现“””
【发布时间】:2016-04-25 02:16:27
【问题描述】:
#! /usr/bin/osascript
osascript -e "do shell script 
"chmod 777 /Library/ColorSync/Profiles" with administrator privileges"

错误: 预期行尾等,但找到“”。

我是苹果脚本的新手。我需要用 NSAppleScript 运行它。作为第一步,我从脚本编辑器收到上述错误消息。

【问题讨论】:

    标签: macos applescript applescript-objc


    【解决方案1】:

    你有#!/usr/bin/osascript shebang。您无需在代码中调用 osascript。做吧:

    #!/usr/bin/osascript
    do shell script "foo"
    

    【讨论】:

    • 执行了这个#! /usr/bin/osascript osascript -e '使用管理员权限执行 shell script "chmod 777 /Library/ColorSync/Profiles" 得到同样的错误。消息不是“”,而是未知字符
    • 查看我的编辑。我忘了这是在脚本中,我没有注意到 shebang
    • #! /usr/bin/osascript osascript -e 使用管理员权限执行 shell 脚本“chmod 777 /Library/ColorSync/Profiles” - 得到相同的错误
    • 不需要在您的脚本中调用osascript,因为shebang 已经使用了AppleScript 命令。仔细阅读第二个脚本。实际上,我将删除第一个。
    猜你喜欢
    • 1970-01-01
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    相关资源
    最近更新 更多