• 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: sudo from nstask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sudo from nstask


  • Subject: Re: sudo from nstask
  • From: April Gendill <email@hidden>
  • Date: Sat, 27 Sep 2003 14:23:42 -0700

On Saturday, September 27, 2003, at 01:43 PM, David Blanton wrote:

> On 9/27/03 1:36 PM, "April Gendill" <email@hidden> wrote:
>
>> Ok.. adding -S to the arguments array DOES NOT invoke super user mode
>> when opening a shell application.
>>
>> so then, how does one launch apt-get, which can ONLY be launched is
>> super user mode.
>> in other words using nstask I need to sudo apt-get
>> how is that possible or is it?
>>
>>
>> April.
>> _______________________________________________
>> 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.
>>
> sudo -S <command> tells sudo to get a password from stdin. It does
> work
> as I have done it with NSTask
>
>
> // allocate a task to execute the script
> NSTask * removeMRTask = [[NSTask alloc] init];
where do I put in the path to the task.
ok look, I've allocated the task, this is what I am using to launch it:

NSString *toolPath =@"sudo -S /sw/bin/apt-get";
NSArray *arguments = [[NSArray alloc]
initWithObjects:@"-q1",@"-f",@"install",wmName,nil];

then i launch the task. which gives me the error launch path not
accessable.
All you show here is the allocation of a task, but how are you entering
the launch path how exactly is this working????
I'm sorry but this does not make any sense at all.

> // we need a pipe for stdin to pass a password to sudo
> NSPipe * stdinPipe = [[NSPipe alloc] init];\

how can you open a pipe if there is no task?
>
> // 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 a stdin for our script task
> [removeMRTask setStandardInput:stdinPipe];
> // set the executable path
> [removeMRTask setLaunchPath:launchPath];
> // start the progress indicator
> [m_progress startAnimation:sender];
> // start the task
> [removeMRTask launch];
> [removeMRTask waitUntilExit];
> status = [removeMRTask terminationStatus];
_______________________________________________
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.

  • Follow-Ups:
    • Re: sudo from nstask
      • From: Chris Hanson <email@hidden>
    • Re: sudo from nstask
      • From: Chris Ridd <email@hidden>
  • Prev by Date: Re: unused parameters
  • Next by Date: Re: sudo from nstask
  • Previous by thread: sudo from nstask
  • Next by thread: Re: sudo from nstask
  • Index(es):
    • Date
    • Thread