Hi all,
I’m not exactly new to AppleScript, but I’m having trouble with a finicky shell script. I’ve searched the forums (and the whole internet for that matter) for advice, but I’m stumped and ready to give up. Here’s the problem part of my script:
try
do shell script "/usr/sbin/chown -R " & userGroup & " " & pathForShell user name "adminUser" password "adminPassword" with administrator privileges
end try
try
do shell script "/bin/chmod -R " & myMode & " " & pathForShell user name "adminUser" password "adminPassword" with administrator privileges
end try
Nothing fancy, right? Simple shell scripts to repair ownership and permissions on a folder. The 100 or so lines of AppleScript that appear before the do shell script command only serve to define the pathForShell variable from a file that’s dropped in a folder (this is a folder action script). userGroup and myMode are pulled from a data list. So the final shell scripts look something like this:
/usr/sbin/chown -R writer:editorial 'quoted/posix/path/to/restricted/directory'
/bin/chmod -R 775 'quoted/posix/path/to/restricted/directory'
Simple, right? Everything I’ve read says I’m sending the right code to the terminal (or where ever it is that shell scripts go), but the chown script refuses to run! The chmod script works fine and both scripts work if I copy and paste my results into the terminal. Just that one script won’t work from AppleScript. It’s driving me crazy!
I pulled the sudo command from the shell script since Apple says it’s unneccesary (in the now-famous Technical Note TN2065) I’m wondering if there’s a way to include the password in the shell script since AppleScript doesn’t seem to be passing it to the system. Or even a way to avoid the shell script and set ownership with the Finder.
Beyond that I’m open to suggestions. Thanks for any help.
Model: Dual 1.8 GHz G5 Tower
AppleScript: 1.10.7
Browser: Firefox 3.0.7
Operating System: Mac OS X (10.4)