• 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: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??


  • Subject: Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??
  • From: Mark Williams <email@hidden>
  • Date: Tue, 4 Oct 2005 18:35:41 -0700

I hadn't thought to try and use a file handle. I'll give this a shot and see what I get, thank you :)

Mark

On Oct 4, 2005, at 5:51 PM, Manfred Bergmann wrote:

Hi.

I do this, do get the STDOUT from a command executed with privileges:

// try to get a NSFileHandle from FileDescriptor
int commPipeFD = fileno(commPipe);
if(commPipeFD > 0)
{
// set receiver for stdout
_stdOutOutputHandle = [[NSFileHandle alloc] initWithFileDescriptor:commPipeFD closeOnDealloc:YES];
[_stdOutOutputHandle autorelease];
[defaultCenter addObserver:self
selector:@selector (stdOutDataReceived:)
name:NSFileHandleReadCompletionNotification
object:_stdOutOutputHandle];
[_stdOutOutputHandle readInBackgroundAndNotify];
}


That makes a NSFileHandle out of a C FILE* pointer.


Cheers, Manfred



Am 05.10.2005 um 10:34 schrieb Mark Williams:


Hi,
Im using:
OSStatus result = AuthorizationExecuteWithPrivileges( auth, copier, 0, args, &dittoOut);
to execute ditto and copy files. I use ditto to preserve the resource fork. Anyway, how do I read the data from dittoOut into a char array or some other string so that I can display it on the screen?
I tried
char inpt;
char line[1024];
int ctr=0;


while(inpt = getc(dittoOut) !=EOF){
    line[ctr] = inpt;
    ctr++;
    }
    line[ctr]='\0'
NSLog(@"%s",line);

but all I get is an empty string.

dittoOut is initialized as FILE * dittoOut = NULL;
i never use fopen because I thought I wasn't suppose to. And according to the man page ditto writes all it's data to stderr when you use the "-V" argument, which is one of the arguments I am passing to the tool.


Can some one help me out ?

Mark.







_______________________________________________ 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: 
 >Reading data from the pipe in AuthorizationExecuteWithPrivileges() ?? (From: Mark Williams <email@hidden>)
 >Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ?? (From: Manfred Bergmann <email@hidden>)

  • Prev by Date: Re: Core Data - awakeFromInsert
  • Next by Date: Linking arrayController selections across Nibs
  • Previous by thread: Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??
  • Next by thread: Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??
  • Index(es):
    • Date
    • Thread