[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
No permisson to read output from NSTask ?
From: |
Yen-Ju Chen |
Subject: |
No permisson to read output from NSTask ? |
Date: |
Tue, 18 Apr 2006 00:15:01 -0700 |
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
- No permisson to read output from NSTask ?,
Yen-Ju Chen <=