• 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 Bash script as root
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run Bash script as root


  • Subject: Re: Run Bash script as root
  • From: Tom Harrington <email@hidden>
  • Date: Wed, 10 Aug 2005 15:51:52 -0600

On 8/10/05, Jerry Brace <email@hidden> wrote:
> I'm trying to run a bash script as root - I am prompting for
> authentication - all of that works great. When it comes time to run
> the script it doesn't seem to do anything (not writing out the echo
> text I have in the script). Even if I put in an invalid name for the
> resource (wakeup.sh) it doesn't throw an error and still prompts
> correctly for the password. Any help would be great!
>

>      NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
>      NSMutableString * path = [thisBundle pathForResource:@"wakeup"
> ofType:@"sh"];

...

>      err = AuthorizationExecuteWithPrivileges(authorizationRef,
>                                              [path cString],
>                                              myFlags, NULL,
> &myCommunicationsPipe);

You don't ever seem to be checking the value of path.  Most likely
it's nil, and you need to debug your NSBundle lookup.

And please don't use -cString; use -UTF8String, or even better,
-fileSystemRepresentation.

--
Tom Harrington
email@hidden
AIM: atomicbird1
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Run Bash script as root (From: Jerry Brace <email@hidden>)

  • Prev by Date: NSNotifications between threads
  • Next by Date: NSImageView, Focus Ring and Resizing
  • Previous by thread: Run Bash script as root
  • Next by thread: NSNotifications between threads
  • Index(es):
    • Date
    • Thread