[help] Apple Scripting!

Hey guys. I have written an Applescript that backs up my iTunes Library info to my other hard drive. I planned to compile this as an app and have it run during every startup. I have the following problem- the code works fine and accomplishes the desired task when run from the compiler, but when saved as a run-only app, I get an error message (error -1344). I haven't been able to figure out what is wrong, and I haven't found out what the error code means, even after searching Google. The code at this point is this:

tell application "Finder"
if file "iTunes 4 Music Library" of folder "backup" of disk "smith" exists then delete file "iTunes 4 Music Library" of folder "backup" of disk "smith"
if file "iTunes Music Library.xml" of folder "backup" of disk "smith" exists then delete file "iTunes Music Library.xml" of folder "backup" of disk "smith"
copy file "iTunes 4 Music Library" of folder "itunes" of folder "music" of folder "adampotts" of folder "users" of disk "neo" to folder "backup" of disk "Smith"
copy file "iTunes Music Library.xml" of folder "itunes" of folder "music" of folder "adampotts" of folder "users" of disk "neo" to folder "backup" of disk "Smith"
end tell

Any help you guys could offer would be great, especially Taha and/or mike273. Thanks guys!

-godpunk

#45284

If its a script, why does it have to be compiled? Can't you just run it? Im sure theres a place in OSX (there is in all unix) that you can put commands that run at localisation, its "rc.local" in Linux/BSD.

Is that applescript? That is the easiest scripting language I have ever seen. Im impressed. And I thought BASH was easy. :lol:

EDIT:\\ Your permissions may be wrong. That tends to be my problem.

#45285

It looks right. So I dunno why you're getting an error. You might want to ask this question over at Spymac.

@Contra: the script can be run normally or made into a stand-alone app. The advantage of the latter (and if I'm correct, the reason why Godpunk wants to do it) is that it can be added to the startup items in the Sys Prefs.

And believe me AppleScript is easy! (Y)

edit: I think it IS the Permissions too, now that I think of it. Perhaps you dont have admin priveleges for the second drive when you boot up.

I'd use Disk Utility (Apps>Utils) to repair the permissions of (ideally) both drives.

Let us know if it works. Or not. :unsure:

#45290

Well, I fixed the disk priveledges. Now I get a -1312 error! :rant:

Back to the drawing board.

-godpunk

#45330

Well, I'm starting to think that privledges may not be the problem in this case- I logged in as root user, and still I get a -1312 error. I dunno if I am coding it wrong or what...it's so odd that it runs fine from the compiler, but not stand-alone. I 'm afraid I will have to ditch this project... :(

-godpunk

#45432

So I was playing with the macs at CompUSA today (the G5s arent out yet <_< ) and I had a hunch, and I was right.

Godpunk: You want that script to run at startup, right? Well, I can help you turn that into a BASH script and you can just stick it in /etc/rc.startup. (I think its rc.startup, check /etc for the rc.* files)

This is the UNIX way to do it, but I checked, and it works fine in OSX.

So talk to me if you want me to help you write a bash script.

Actually, you may just be able to run the Applscript. Try saving that script out in a normal text editor.

Then in a console:

chmod +x [nameoffile]

then

./[name of file]

that should run the script. If it works, stick an entry in /etc/rc.startup for it.

#47362

LOL, I have to agree with contra, if thats AppleScript then it seems that HTML is almost more complicated that THAT!

#47379