• 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
Paths & quoted form & do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Paths & quoted form & do shell script


  • Subject: Paths & quoted form & do shell script
  • From: Martin Orpen <email@hidden>
  • Date: Sat, 08 Oct 2005 22:55:11 +0100
  • Thread-topic: Paths & quoted form & do shell script

There is probably a simple explanation for this - but I'm so bored with
trying different variations that I can't see it :-(

If I do this - the aim being to feed a path as a string to a grep one-liner:

    set theFile to choose file
    set bar to ((POSIX path of theFile) as string)
    do shell script "/usr/bin/grep -i saved " & quoted form of bar

Everything works as expected.

But, I wanted my script to check a text file that may have been written to
disk the previous time that the script was run and grab the file path from
that file.

When I do that I get the shell choking on the path:

    set tFile to (path to temporary items as string) & "PSLogTest.txt"
    set thePath to paragraph 1 of (read file tFile)
    do shell script "/usr/bin/grep -i saved " & quoted form of thePath

    -->
    sh: -c: line 1: unexpected EOF while looking for matching `''
    sh: -c: line 2: syntax error: unexpected end of file


And, what is really annoying is that if I change the last line of that
script to:

    set the clipboard to "/usr/bin/grep -i saved " & quoted form of thePath

And then paste the result into Terminal - it works as expected!

I need to use "quoted form of" because the path has spaces. But why is do
shell script choking on the quotes and the Terminal accepting the pasted
version without a problem?

BTW, is there an easy way of getting an *escaped form* of a POSIX path
without having to write a handler to do it?

--
Martin Orpen


 _______________________________________________
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

  • Follow-Ups:
    • Re: Paths & quoted form & do shell script
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: Best practice for activation of another application
  • Next by Date: Re: Paths & quoted form & do shell script
  • Previous by thread: Re: Best practice for activation of another application
  • Next by thread: Re: Paths & quoted form & do shell script
  • Index(es):
    • Date
    • Thread