【发布时间】:2014-01-05 02:44:31
【问题描述】:
我只是无法理解这个:( 我想将用户(例如 Joe Smith)添加到一个(或多个)文件夹的权限中。我用以下代码创建了一个小程序:
on open thisStuff
try
tell application "Finder"
repeat with this_item in thisStuff
set thisObj to POSIX path of (alias this_item)
set scrpt to quoted form of ("chmod -a \"joesmith:allow:read\"")
do shell script scrpt & " " & thisObj with administrator privileges
end repeat
end tell
on error errStr number errorNumber
error errStr number errorNumber
end try
end open
当我将文件夹放到小程序上时,出现“找不到命令”错误。
如果我进入终端中的正确目录并输入:
chmod +a "joesmith:allow:read" my folder
它可以正常工作。 我猜我的转义或我的 shell 脚本的其他语法有问题,但我就是看不到它:( 任何人都可以请我直接在这里...
编辑……
仍然在破解它!我试过这样:
on open thisStuff
set pass to "mySecretPassword"
try
tell application "Finder"
repeat with this_item in thisStuff
set thisObj to POSIX path of (alias this_item)
do shell script "sudo chmod -a " & "access_bpf:allow:read " & quoted form of thisObj password pass with administrator privileges
end repeat
end tell
on error errStr number errorNumber
error errStr number errorNumber
end try
end open
...这次我得到了错误:
chmod: No ACL present 'Volumes/Path/to/my/folder/'
Mmmmmmmm……我想不通!
再次感谢您的帮助:)
【问题讨论】:
标签: shell applescript