• 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: Changing ownership of a folder and all contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing ownership of a folder and all contents


  • Subject: Re: Changing ownership of a folder and all contents
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 16 Aug 2007 15:14:58 -0400

On 8/16/07, Terry Sheltra <email@hidden> wrote:
> I've also tried what you suggested, using the "with administrator
> privileges," but I get an error saying there was a privilege violation, I'm
> guessing because you must be root to muck around with users' home
> directories.  That's why I'm piping the password in to sudo.

Hm.  I thought "do shell script with administrator privileges" did run
the command as root?

> As an example, say my password is
>
> p!assword
>
> the script works just fine, piping in the password from the Pass variable,
> however what happens if I try the same thing in a Terminal window is:
>
> !assword: No such event

that's just quoting problems.  The same thing happens if you just type

echo p!assword

by itself.  The ! is a special character that tells the shell to look
through past commands and include the last one that started with what
comes next, in this case "assword".  Single-quoting it removes that
issue:

echo 'p!assword'

> I don't anticipate there being any problem if the user's password doesn't
> contain any odd characters, but if it does, it throws an error.

That's what { quoted form of } is for:

do shell script "echo " & quoted form of Pass & " | sudo ..."

It's smart enough to handle things like embedded quotation marks or
apostrophes and all that, so it's better than trying to do the quoting
yourself manually as you build the string.

Note: on Tiger you may need to pass the -S option to sudo to convince
it to read the password from the pipe instead of from the terminal,
although it may also figure that out on its own if it has no
controlling terminal to read from.

--
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

  • Follow-Ups:
    • Re: Changing ownership of a folder and all contents
      • From: "Reese, Stevan" <email@hidden>
References: 
 >Changing ownership of a folder and all contents (From: Terry Sheltra <email@hidden>)
 >Re: Changing ownership of a folder and all contents (From: "Mark J. Reed" <email@hidden>)
 >Re: Changing ownership of a folder and all contents (From: Terry Sheltra <email@hidden>)

  • Prev by Date: Getting Returned Properties to the Clipboard or a Text Log
  • Next by Date: Re: Getting Returned Properties to the Clipboard or a Text Log
  • Previous by thread: Re: Changing ownership of a folder and all contents
  • Next by thread: Re: Changing ownership of a folder and all contents
  • Index(es):
    • Date
    • Thread