Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'osascript, shebang, and unicode arguments' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
osascript, shebang, and unicode arguments
Authored by: wgscott on May 02, '06 08:52:54AM
Your life might get a bit easier with a "here document" construct. The following example runs applescript code for a directory browser from within a shell script, and returns the full posix path of the chosen directory:
    link


[ # ]
osascript, shebang, and unicode arguments
Authored by: jctull on May 02, '06 11:11:36AM

He mentioned this, and his reason it was not adequate, about two paragraphs after the summary post.



[ # ]
osascript, shebang, and unicode arguments
Authored by: wgscott on May 02, '06 01:45:31PM
You are right -- I missed it. Damn the NyQyl (TM) hangover. But either I don't understand the objection, or else it is mistaken. Here is another, slightly more complex example:
    osa_display_dialog
Invoke with the command:
osa_display_dialog  foo  bar  foobar
This gives three buttons, the third as the default, and returns the user's choice. I didn't escape anything...

[ # ]
osascript, shebang, and unicode arguments
Authored by: mzs on May 02, '06 06:44:10PM
Your first script works, your second does not. Here is what I am talking about. (I just figured-out how to use Polish characters on this site.) Suppose I have this directory:

~/Ł

And I choose it with your first script:


% /bin/zsh -f osa_direc_browser | xxd
0000000: 2f55 7365 7273 2f6d 7a73 2fc5 812f 0a    /Users/mzs/../.
See the c5 81 in the hexdump? That is the UTF-8 for "LATIN CAPITAL LETTER L WITH STROKE". Replacing "choose folder" with "choose file" in your script does the right thing for files too. But what is the point of a shell script that makes you choose the files one by one in a dialog box, I want them from the command line and besides the arguments need not be files, but simply strings.

Now I have a file DŁN.JPG and your second script has this output:


% /bin/zsh -f osa_display_dialog bar.jpg *.JPG | xxd
0000000: 44e2 8988 c385 4e2e 4a50 470a            D.....N.JPG.
See the hex e2 89 88 c3 85, that is all messed-up, since my encoding is macroman. Also the text is munged in the dialog box itself. The hint offers a way for passing arguments to an AppleScript from the command line without arguments with international characters such as Ł getting munged.

[ # ]
osascript, shebang, and unicode arguments
Authored by: wgscott on May 02, '06 07:44:08PM

The point is to use them as building blocks for more complicated GUI scripting. By themselves, they aren't worth much.

Anyway, I now understand the problem. Thanks!



[ # ]