• 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: Shell Script's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell Script's


  • Subject: Re: Shell Script's
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 10 Mar 2008 10:25:05 -0700

On Mar 9, 2008, at 8:38 PM, Connor DiPietro wrote:

I am trying to make and an application in Xcode written in applescript, and when someone clicks a button i want to preform a shell script. i Am having difficulty preforming the shell script (let's say x's represent the shell script)

do shell script "xxxxxxxxxx"xxx"xxxxx xxx xxx"

When i try do execute this scrip i get an error because the shell script has quotations inside of quotations and applescript handles this like two different shell scripts. how can i make this work!!!


Quoting from <http://developer.apple.com/technotes/tn2002/tn2065.html>:

Q: I need to put double quotes and backslashes in my shell command, but AppleScript gives me a syntax error when I try.

A: Strings in AppleScript go from an opening double quote to a closing double quote. To put a literal double quote in your string you must "escape" it with a backslash character, like this:

	"a \"quote\" mark"

The backslash means "treat the next character specially." This means that getting a literal backslash requires two backslashes, like this:

	"a back\\slash"

Putting this all together, you might have something like this:

set s to "this is a test."
do shell script "echo " & quoted form of s & " | perl -n -e 'print \"\ \U$_\"'"
-- result: "THIS IS A TEST."


Despite all the extra backslashes in the script, the actual string passed to perl’s -e option is

	print "\U$_"


Also see the question immediately above that one, which talks about the "quoted form" property.



--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Shell Script's (From: Connor DiPietro <email@hidden>)

  • Prev by Date: Re: New Error -8086
  • Next by Date: Re: Compiling as Application Bundle vs. Application
  • Previous by thread: Re: Shell Script's
  • Next by thread: Office 2008 - How to build up menus and how to catch the events
  • Index(es):
    • Date
    • Thread