discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No permisson to read output from NSTask ?


From: Yen-Ju Chen
Subject: Re: No permisson to read output from NSTask ?
Date: Tue, 18 Apr 2006 00:30:49 -0700

Just figure out that I should use NSPipe.

Yen-Ju

On 4/18/06, Yen-Ju Chen <yjchenx@gmail.com> wrote:
> I try to use NSTask to execute a perl scripts and read the result from
> NSFileHandle.
> But NSFileHandler raises an exception about having no permission to
> read the output.
> The scripts belongs to me and I have no problem running it.
> NSFileHandle indeed can read the output *after* raise the exception.
> I also try other scripps and have the same result.
> Is there anything I did wrong ?
> Do I need a special permission to read from standard output ?
> How do I set it programmingly ?
>
> Here is the code:
>
>     NSFileHandle *f_output= [NSFileHandle fileHandleWithStandardOutput];
>     NSTask *task = [[NSTask alloc] init];
>     [task setStandardOutput: f_output];
>     [task setLaunchPath: command];
>     [task launch];
>     NSData *data = [f_output readDataToEndOfFile];
>     NSString *s = [[NSString alloc] initWithData: data encoding:
> [NSString defaultCStringEncoding]];
>     NSLog(@"%@", s);
>     return;
>
> Thanx.
>
> Yen-Ju
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]