| |
| | |

Apple Phoon Forum

 Forgot password?
 Register
View: 1048|Reply: 6

Error while wrting data into file using Applescript

[Copy link]

Post time: 2013-01-04 06:40:40 |Show all posts
AppleScript
am using the below script for writing the file, but sometimes am getting errors like mentioned below, pls suggest..
set filepath to POSIX path of
"Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
try tell application
"System Events"
if file filepath exists then set myFile to open for access file filepath with write permission set fileData to read myFile set eof myFile to 0 write
"blah blah"
to myFile close access myFile else return
"File Not Found"
end if end tellon error return falseend try
Error:
"Network file permission error."
number -5000 from file
"Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
Also some times i will get this error, am unable to close the opened file
"File file Macintosh HD:Library:Application Support:Macromedia:mms.cfg is already open."
number -49 from file
"Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
When i tried to close the ofile am getting this eror:
on openAFile(filepath) try set fp to open for access filepath with write permission on error errstr number errNum if errNum = -49 then close access filepath set fp to open for access filepath with write permission else display dialog errstr return false end if end try return fpend openAFileset pointer to openAFile(
"Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
set fileContents to read pointer
Error
"Can’t make \"Macintosh HD:Library:Application Support:Macromedia:mms.cfg\" into type file."
number -1700 from
"Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
to file
         Mac OS X (10.7.4)
Reply

Use magic Report

Post time: 2013-01-04 15:05:02 |Show all posts
Hi,
is their any way to solve the permission error??
Reply

Use magic Report

Post time: 2013-01-04 13:32:48 |Show all posts
First fix your own - it is sentence not sentance. You don't know whether the OP has English as a first language, never mind the education level completed.
Reply

Use magic Report

Post time: 2013-01-04 11:50:06 |Show all posts
Those were intended as examples, not implementations. You shouldn't generally use the alias keyword with a slash-delimited path. why don't you show he current version of the script (so I can see exactly what you did).
oh, and **** me for an old ****, but please: the English sentance is "I implemented your changes but the problem still exists". I don't mind that stuff in texting, but on a public forum it makes you look like you topped out at a third-grade education. Not at all inspiring...
Reply

Use magic Report

Post time: 2013-01-04 10:44:22 |Show all posts
Well error -49 is that the file is already open. So if you run the script and it opens the file but you get the error -5000 and the script aborts then when you run the script again the file is open as far as the editor is concerned and you get the -49 error.
The only way I know to clear that is to quit he script editor and reopen it. That should eliminate the -49 error Not sure what the -5000 is telling you, trying to look it up now.
Message was edited by: Frank Caggiano - -5000 is path or permission problem on the file
Reply

Use magic Report

Post time: 2013-01-04 09:02:56 |Show all posts
Hi,
thanks for reply, i implemented ur changes but still prob exists..
error :
error "System Events got an error: Bad name for file. alias /Library/Application Support/Macromedia/mms.cfg" number -37
Reply

Use magic Report

Post time: 2013-01-04 07:51:49 |Show all posts
if you're using HFS (colon-delimited) file paths, then you always have to prefix it with the file or alias keywords. If you don't, Applescript will see it as a plain sting rather than a file path. You can use POSIX (slash-delimited) paths directly. examples:
set filepath to POSIX path of file "Macintosh HD:Library:Application Support:Macromedia:mms.cfg"
set fp to open for access alias filePath with write permission
Reply

Use magic Report

You have to log in before you can reply Login | Register

Archive| Apple Phoon

2017-11-18 22:45 GMT-8 , Processed in 0.167236 sec., 27 queries .

Powered by Discuz! 7.2

Release 20121101, © 2001-2017

To Top