• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do shell script bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script bug


  • Subject: Re: do shell script bug
  • From: John Delacour <email@hidden>
  • Date: Mon, 12 Aug 2002 21:33:51 +0100

Sounds like you know about this.

But my problem is actually slightly different. I'm running a
do shell script "'shell script that returns Unicode'"

And it's been changed to
do shell script "'shell script that returns Unicode' > /path/to/file"

and then I do
do shell script "perl -e 'open F, qq(/path/to/file); print <F>'"

and the perl line gives me the error I'm trying to avoid!


I can only guess that you have a single quote or something in the string that you pass to the command line. This is the trouble with using uncontrollable strings in the command line. It's best to write the string to a file in Temporary Items Folder and get perl to read the string from there. That way you avoid actually having rogue characters cause trouble.

This script does the equivalent of what you appear to be doing. I'm afraid I don't talk much shellingo, so it's all in perl. Notice how I've had to use backticks to avoid using ' in the comment lines, and that I cannot use the hash either.

The script creates a file, writes unicode to it and displays the result in the all-singing, all dancing most worthy successor to the stupendous SimpleText -- I give you TextEdit!


set dox to "" & (path to +constant afdrdocs;)
-- (french quotes round the constant for 7-bit victims)
set pathname to dox & "aaa.txt"
set f to POSIX path of pathname
do shell script "cd / ; perl -e '
$f = qq (" & f & ") ;
q| create the file `aaa.text` |;
open F, qq(>$f) ;
q| Write the Unicode signature + three fancy a`s |;
print F chr(254). chr(255).
qq(\\000\\xe2\\000\\xe3\\000\\xe4);
close F;
q| Read the file and open it in TextEdit |;
open F, q (" & f & ") or die $! ; print <F> ;'"
tell application "Finder" to open alias pathname

JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • 1.8.3
      • From: John Delacour <email@hidden>
References: 
 >Re: do shell script bug (From: email@hidden)

  • Prev by Date: Re: Display dialog Return - Bug or Feature?
  • Next by Date: Re: Display dialog Return - Bug or Feature?
  • Previous by thread: Re: do shell script bug
  • Next by thread: 1.8.3
  • Index(es):
    • Date
    • Thread