Thank you Mario, the sudo <echo password thing looks like it might do what I 
need...  I will give it a try and see if that does the trick.

Jeff

On Apr 8, 2013, at 11:51 AM, Mario Steele wrote:

> Hey Jeff,
> 
> While this is probably not the MacRuby way, this is the Linux Ruby way, and 
> should translate over well to Mac OS X.  To have your script run as Root, you 
> simply do the following:
> 
> if Process::UID.euid != 0 || Process::UID.rid != 0
>   # Prompt for Password here with a Custom GUI
>   `sudo #{__FILE__} < echo #{password}`
>   # OR if your not totally oblivious to using osascript to launch your Ruby 
> App
>   #`osascript -e do shell script "#{__FILE__}" with administrator privileges`
>   exit!
> end
> 
> But I don't know if this would work with MacRuby's setup.  Haven't really 
> messed with it in a while.
> 
> hth,
> 
> Mario
> 
> 
> On Mon, Apr 8, 2013 at 2:08 PM, Jeff Dyck <fsjj...@gmail.com> wrote:
> Hey all, I'm desperately hoping for some help here...
> 
> I'm a System Admin for a School District with thousands of Macs.  In the past 
> I developed an AppleScript Studio application that our technicians used to 
> backup and restore user accounts when we do system migrations and image 
> updates (basically rsync with some internal logic to filter out files that 
> might conflict).
> 
> Anyway, with AppleScript Studio long deprecated, we're starting to see some 
> issues with it running on 10.8, so I've started working on a replacement in 
> MacRuby (which I've started to move to for other development)... I love Ruby 
> vs the pain of AppleScript, especially for things like dealing with xml and 
> whatnot, but I'm running into one HUGE challenge...
> 
> My app requires admin privileges to backup and restore user accounts and 
> restore permissions.  In AppleScript Studio this was relatively simple to do 
> using the "do shell script with admin privs' command.  In MacRuby.... I'm 
> stumped.
> 
> I've dug in a bit into the Authorization framework, and looked at some of 
> Apple's documentation for splitting your app into helper tools... but it's 
> difficult enough to follow the Obj-C stuff, migrating that to Ruby is 
> probably over my head.
> 
> So long story short, anyone have some samples of how to do this with MacRuby? 
>  I'd need to be able to do things like:
>         • Calculate size of folders and count of files in another user 
> account (and get result back)
>         • Send an RSYNC command as admin (and get feedback for calculating 
> progress)
> 
> Here's hoping someone can point me in the right direction. Thanks in advance.
> 
> Jeff
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> 
> 
> -- 
> Mario Steele
> Fleet Captain
> CO - Geo 99
> CO - USS T'hy'la
> XO - Diplomatic Corps - Second Life
> http://www.iftcommand.com/chapters/thyla/
> http://www.trekfederation.com
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macruby-devel

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macruby-devel

Reply via email to