So currently I'm working on a little personal project that runs a bash script in a resources bundle, and I can get it to properly output the console log to NSLog, but the strings won't rewrite an NSTextField or redraw an NSTextView
- (IBAction)doIt:(NSButton *)sender
{
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
NSArray *arguments;
NSString* newpath = [[NSBundle mainBundle] pathForResource:@"run" ofType:@"sh"];
NSLog(@"shell script path: %@",newpath);
arguments = [NSArray arrayWithObjects:newpath, nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
NSPipe *input = [NSPipe pipe];
[task setStandardOutput: pipe];
[task setStandardInput: input];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
NSData *data;
data = [file readDataToEndOfFile];
NSString *string;
string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog (@"script returned:\n%@", string);
}
So the string at the end will output properly with NSLog, but that's all I can do... any ideas?