Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > osascript misbehavior on fancy apostrophe

osascript misbehavior on fancy apostrophe
Thread Tools
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jun 12, 2005, 12:11 PM
 
This sounds like the stupidest problem I've ever encountered, but here it is.

I need to use osascript in a shell script of mine to enable ownership on a disk. That's done like so:
Code:
tell application "Finder" to set ignore privileges of disk "My iPod" to false
This works just fine, except when the disk name contains a fancy apostrophe, namely
which is U+2019 "RIGHT SINGLE QUOTATION MARK" according to UnicodeChecker. The bad news is that this apostrophe is in the default iPod name, such as "Jim’s iPod."

When called from the command line, I get an error like
Code:
29:83: execution error: Finder got an error: Can't set ignore privileges of disk "This guy’s iPod" to false. (-10006)
When run from within ScriptEditor it works just fine.

Is there any way I can get this to work from the command line? Is it an encoding issue?
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Jun 12, 2005, 09:31 PM
 
Well, if it's always the same name, you can just save the compiled script somewhere and run that with osascript.
Or maybe you can use this little python script to generate portable Applescript that encodes the string.
     
wataru  (op)
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jun 12, 2005, 09:48 PM
 
The name must be dynamic. It's discovered from the path of the iPod in question with
Code:
$(echo $DESTINATION | awk -F/ '{print $3}')
where $DESTINATION might be /Volumes/Jim’s iPod.

I'll look at that Python script, but I'd like to try to keep this project to as few languages as possible.
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Jun 13, 2005, 12:15 AM
 
other ideas:
* do the whole thing in applescript
* export the volume name to an environment variable and recover it with system attribute "DESTINATION"
* write the volume name to a file, and read it back in the script ( http://www.satimage.fr/software/en/u...plescript.html )
     
wataru  (op)
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jun 13, 2005, 12:30 AM
 
Originally Posted by Mithras
other ideas:
* do the whole thing in applescript
* export the volume name to an environment variable and recover it with system attribute "DESTINATION"
* write the volume name to a file, and read it back in the script ( http://www.satimage.fr/software/en/u...plescript.html )
Thanks for the suggestions.

My script is over 500 lines long. I don't want to redo it in AppleScript, partly because I don't know enough AppleScript to duplicate all of the functionality.

I tried exporting the environment variable, but I ran into the exact same encoding issue.

I also tried reading from a file, but got the same encoding issue when reading as ASCII text, and a different one when reading as Unicode text.

I'll keep trying stuff. Thanks guys.

Edit: Writing to a file worked after playing with the encoding some more. This whole problem strikes me as very stupid. Why doesn't the string get passed to AppleScript properly even after converting to UTF-16 while still in the command line?
(Last edited by wataru; Jun 13, 2005 at 12:48 AM. )
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2