• 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: Cocoa/run sudo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa/run sudo


  • Subject: Re: Cocoa/run sudo
  • From: David Blanton <email@hidden>
  • Date: Tue, 02 Sep 2003 13:26:51 -0600

This works for me ... You need sudo -S to take the password from stdin


// we need a pipe for stdin to pass a password to sudo
NSPipe * stdinPipe = [[NSPipe alloc] init];
// to write to the pipe we need a file handle
NSFileHandle * pipeWrite = [stdinPipe fileHandleForWriting];
// can only write NSData to a file handle
NSData * password = [user_password dataUsingEncoding:NO];
// write the data and close the pipe
[pipeWrite writeData:password];
[pipeWrite closeFile];
// set the pipe to stdin for our script task
[removeMRTask setStandardInput:stdinPipe];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Cocoa/run sudo (From: Michael Mulligan <email@hidden>)

  • Prev by Date: Re: plug-in problem
  • Next by Date: Re: Painting into a NSImage / Combining two NSImage objects
  • Previous by thread: Re: Cocoa/run sudo
  • Next by thread: Painting into a NSImage / Combining two NSImage objects
  • Index(es):
    • Date
    • Thread