Re: Reading data from the pipe in AuthorizationExecuteWithPrivileges() ??
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