0

I'm trying to use AppleScript to modify some app settings. The code looks like this:

#!/bin/sh

echo '
 tell application "Finder"
   tell disk "'$1'"
       open
       set current view of container window to icon view
       ...
       close
   end tell
end tell
' | osascript

However, I keep on getting a -10810 error code when applescript hits "open" ("64:68: execution error: An error of type -10810 has occurred. (-10810)"). I've done some googling and all I got was "reboot and wait, it sometimes magically starts working" (it didn't).

The machine is running Mac OS Server 10.6. I though it perhaps might be some permissions issue, but running the command as root returns the same error.

Update: Solved (well, more or less :-) ). The thing is that "open" needs a UI. And the problem was that I was using ssh to run the script (which I didn't mention here, because I didn't think it was relevant). So there was no UI. It works when I log in using VNC first.

3
  • Just so you know, you don't need (and probably shouldn't have) a #!/bin/sh line at the beginning. You're not running this via sh, you're running it via applescript.
    – eykanal
    Feb 23, 2011 at 18:09
  • 1
    He is running it as a shell command. Look closer. He's passing in an argument via the command line. The problem of checking whether someone is logged in (and you can run Applescript) is a tricky one a lot of people forget about. If you want to test to ensure someone is logged in you can run the shell command "users" which lists currently logged in users. Obviously this will not return any user if no-one is logged in.
    – Clark
    Feb 23, 2011 at 18:15
  • If you've solved the problem, please post your solution as an answer below and accept it. Mar 11, 2012 at 9:06

1 Answer 1

0

Solved (well, more or less :-) ).

The thing is that "open" needs a UI. And the problem was that I was using ssh to run the script (which I didn't mention here, because I didn't think it was relevant). So there was no UI. It works when I log in using VNC first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.