• 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: Run As Root
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run As Root


  • Subject: Re: Run As Root
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 12 Oct 2011 18:15:21 -0500

On Oct 12, 2011, at 4:39 PM, Stan Cleveland wrote:

This should take care of it:

do shell script "softwareupdate -l" with administrator privileges user name"lutherf" password "blah"

The "user name" and "password" parts are optional. If not supplied, the script will prompt for the information.

I used softwareupdate twice in my script, so I used something a bit more complicated ...

if not my userIsAdmin() then
display dialog "You are not an administrative user." buttons {"Quit"} default button 1
return
end if
tell application "System Events" to set userName to name of current user
"Enter the password for the user \"" & userName & "\""
display dialog the result default answer "" buttons {"Cancel", "Enter"} default button 2 with hidden answer
set pWord to text returned of the result
do shell script "softwareupdate -l" user name userName password pWord with administrator privileges
set response to (the result as text)

on userIsAdmin()
set uid to do shell script "id -u"
set AppleScript's text item delimiters to {space}
do shell script "id -Gn " & uid
(text items of the result) as list
return "admin" is in the result
end userIsAdmin ---------------------------------------

It seems to be working in Lion, now. Thanks.

 _______________________________________________
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:
    • Mail Rule Finder
      • From: Gil Dawson <email@hidden>
References: 
 >Run As Root (From: Luther Fuller <email@hidden>)
 >Re: Run As Root (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: How do I set the focus to the Icon of the Information Window ?
  • Next by Date: Mail Rule Finder
  • Previous by thread: Re: Run As Root
  • Next by thread: Mail Rule Finder
  • Index(es):
    • Date
    • Thread