Sunday, August 20, 2017

#1 2017-04-20 11:14:02 am

Eseye
Member
Registered: 2016-09-26
Posts: 6

Applescript File not open with write permission error

I have an applescript that works perfectly on my local machine.  It opens the file and writes to it and then closes.  My Applescript is being tested and saved as a .app so it is an application.  When I put the application on my server to test out the user experience it never propely opens the file and gives me this error:

"File not open with write permission.
Finder got an error: File not open with write permission. (-61)"

Why would this work on my local machine and not work after being downloaded from my server?  I have tested that my path's are correct and like I mentioned everything works perfectly on my local MAC machine.  I have tried everything...making it a POSIX file, alias, text, string and nothing ever works.  Here is the section of my Applescript code that seems to be throwing the error:

Applescript:


set motionFullPath to ("" & pathGenerators & "" & generatorPlugin & ":" & theFolders & ":" & lastLayer & ":" & motionFiles & "") as string
                       
                       set myFile to open for access file motionFullPath with write permission
                       set endOfFile to (get eof myFile) as number
                       if result > 0 then
                           set theText to read myFile
                           set eof myFile to endOfFile
                           write "<!--uuid:" & theURL & "-->" & return & theText to myFile
                       end if
                       close access myFile

Last edited by Eseye (2017-04-20 11:15:41 am)


Filed under: applescript, Permissions

Offline

 

#2 2017-04-21 02:33:05 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 539

Re: Applescript File not open with write permission error

The error suggests there's a problem with the path. Show us how the script gets that path.

Offline

 

#3 2017-04-21 03:11:44 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4351

Re: Applescript File not open with write permission error

I can't see anything in the posted code which would cause the problem. The lines between the opening and closing of the access aren't protected by a try statement, but if the script's an applet, anything it opens should be closed anyway when it crashes or quits. I'm not clear if the script's being run remotely (in which case there may be security issues) or downloaded and run on the users' machines.

Just to point out that, as posted, the code appends the modified text to the end of the current text. If it's meant to replace it, set eof myFile to 0 instead.


NG

Offline

 

#4 2017-04-21 10:19:44 am

Eseye
Member
Registered: 2016-09-26
Posts: 6

Re: Applescript File not open with write permission error

Well I came across the issue which is that my .app is quarantined.  But I am super confused how can my .app be properly codesigned and yet still be quarantined by Apple?  I have an app called iTest.app that I downloaded from my server and made sure that it was codesigned correctly but yet it is still quarantined?  I thought that having a valid code signature was the whole point of getting past Gatekeeper? 


MyMac-7:Downloads user$ ls -l@ iTest.app
total 0
drwxr-xr-x@ 7 user staff  238 Apr 21 08:05 Contents
    com.apple.quarantine     67

MyiMac-7:Downloads user$ codesign --verify --deep --strict -vvvvvvv iTest.app
iTest.app: valid on disk
iTest.app: satisfies its Designated Requirement

MyiMac-7:Downloads user$ spctl -a -t exec -vvvvvvv iTest.app
iTest.app: accepted
source=Developer ID
origin=Developer ID Application: myID

Offline

 

#5 2017-04-21 06:21:13 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5079

Re: Applescript File not open with write permission error

Eseye wrote:

I am super confused how can my .app be properly codesigned and yet still be quarantined by Apple?


Everything downloaded is quarantined, regardless of code-signing. It means you get the confirmation dialog the first time you run it, after which the quarantine bit is removed.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)