Re: Paths & quoted form & do shell script
Re: Paths & quoted form & do shell script
- Subject: Re: Paths & quoted form & do shell script
- From: Christopher Nebel <email@hidden>
- Date: Mon, 10 Oct 2005 08:07:29 -0700
On Oct 9, 2005, at 3:11 PM, Martin Orpen wrote:
on 9/10/05 21:07, Gary (Lists) at email@hidden wrote:
Given your skills and formidable big brain, you've probably ruled
that out
already, but in case not...
I've solved the problem now - and can report that it's a problem
that I
caused in the first place :(
This works:
set myData to choose file
set myData to POSIX path of myData as string
set posixT to path to temporary items
set f to open for access file ((posixT as string) & "mytemp99")
with
write permission
write myData to f
close access f
set tFile to (path to temporary items as string) & "mytemp99"
set thePath to paragraph 1 of (read file tFile) as Unicode text
do shell script "/usr/bin/grep -i open " & quoted form of thePath
However, if you *ever* fail to coerce the POSIX path from the
second line to
a string before writing to the file your script gets hosed *forever*!
I edited the script over and over again. I coerced Unicode text to
a string,
but it made no difference because (I'm guessing) the string would
not fully
overwrite the Unicode text that I'd mistakenly saved at one point
during
writing and testing the script.
Hope that helps somebody who has fallen into the same trap - the
safest
thing to do is rename the temp file and move on...
"write" is defined to *not* alter the end-of-file mark except to make
it bigger. Therefore, if you want to write data to an existing file,
you should "set eof ... to 0" first. (Is this awkward? Yes. Can we
change it? No. Welcome to the world of Backward Compatibility.)
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden