• 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: Summary: Formatting question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Summary: Formatting question


  • Subject: Re: Summary: Formatting question
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 20 Apr 2007 16:03:59 -0400

On 4/20/07, Chris Waldrip <email@hidden> wrote:
Mark Reed was kind enough to point out my simple mistake

I was just the first. Lots of kind folks on this list had the answer...

do shell script "scutil --set ComputerName \"" & machineName & "\""
with administrator privileges

Instead of doing your own manual quoting with \" in the strings, I'd replace { machineName } with { quoted form of machineName }, which puts the whole thing in single quotes (so any accidental shell metacharacters don't get expanded) and also handles anything like embedded quotation marks (such as an apostrophe-s in a filename, for instance).

Of course, none of this is necessary in this case since you just
constructed machineName and know that it's a single word with no
spaces or special characters, so you don't really need any quotation
marks at all.  But it's a good general practice when including strings
in do shell scripts.

--
Mark J. Reed <email@hidden>
_______________________________________________
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: 
 >Formatting question (From: Chris Waldrip <email@hidden>)
 >Summary: Formatting question (From: Chris Waldrip <email@hidden>)

  • Prev by Date: Summary: Formatting question
  • Next by Date: Re: Formatting question
  • Previous by thread: Summary: Formatting question
  • Next by thread: Re: Formatting question
  • Index(es):
    • Date
    • Thread