• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Applescript complaining about accessing and writing to a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript complaining about accessing and writing to a file


  • Subject: Re: Applescript complaining about accessing and writing to a file
  • From: Paul Taylor <email@hidden>
  • Date: Fri, 25 Oct 2013 11:02:51 +0100

On 25/10/2013 10:57, Paul Taylor wrote:
I get the error message

25/10/2013 10:39:39.816 iTunes[3366]: AppleEvents/sandbox: Returning errAEPrivilegeError/-10004 and denying dispatch of event rdwr/writ from process 'AppleScript Editor'/0x0-0x24d24d, pid=12717, because it is not entitled to send an AppleEvent to this process.

The errors message occurs every time we access the file /tmp/jaikoz_itunes_model.txt, so for the following lines

set fileref to open for access (thePath) with write permission (one message)
set eof fileref to 0 (one message)
write nextline & "\n" as "utf8" to fileref  starting at eof (once per song in itunes)
close access fileref (one message)

so the problem is not that we cant talk to itunes but that iTunes isn't allow to do things with the filesystem
It still writes to the file regardless but I think these error messages are slowing it down

Am I writing to the file in the wrong place or something ?

tell application "iTunes"
    set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt")
    set fileref to open for access (thePath) with write permission
    set eof fileref to 0
    set mainLibrary to library playlist 1
    repeat with nexttrack in (get every track of mainLibrary)
        if (class of nexttrack is file track) then
            try
                set trackname to name of nexttrack
                set loc to location of nexttrack
                set locpath to POSIX path of loc
                set persistid to persistent ID of nexttrack
                set nextline to trackname & "::" & locpath & "::" & persistid
                write nextline & "\n" as "utf8" to fileref  starting at eof
            end try
        end if
    end repeat
    close access fileref
end tell
return ""



Paul

So Ive worked out that if take the file open and close calls outside of the tell block then they no longer give a error message, however I cant see how I can take the write out of the tell block

this is what I now have

set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt")
set fileref to open for access (thePath) with write permission
set eof fileref to 0
tell application "iTunes"  
    set mainLibrary to library playlist 1
    repeat with nexttrack in (get every track of mainLibrary)
        if (class of nexttrack is file track) then
            try
                set trackname to name of nexttrack
                set loc to location of nexttrack
                set locpath to POSIX path of loc
                set persistid to persistent ID of nexttrack
                set nextline to trackname & "::" & locpath & "::" & persistid
                write nextline & "\n" as "utf8" to fileref  starting at eof
            end try
        end if
    end repeat
end tell
close access fileref
return ""


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Applescript complaining about accessing and writing to a file
      • From: Shane Stanley <email@hidden>
References: 
 >Applescript complaining about accessing and writing to a file (From: Paul Taylor <email@hidden>)

  • Prev by Date: Applescript complaining about accessing and writing to a file
  • Next by Date: Re: Article on missing Applescript in new iWork
  • Previous by thread: Applescript complaining about accessing and writing to a file
  • Next by thread: Re: Applescript complaining about accessing and writing to a file
  • Index(es):
    • Date
    • Thread