Re: Cocoa/run sudo
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 write
Data: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.