nstextview - Getting output of a shell script in Cocoa -


Is there a way that runs a shell script and displays output in NSTextView? I do not want any input on the shell script from the user, because it is only asked to compile a collection of files. The shell script part works fine so far, but I did not know how to run it and showing the output in NSTextView. I know that a shell script can be run using the system () and NSTK, but how do I get this output into NSTextView?

If you want the wildcard extension, then your unix command should be / bin / sh

  - (NSString *) unixSinglePathCommandWithReturn: (NSString *) command {// gives a stdout by sending / bin / sh to a UNIX command. // Behind the Trims Carriage return / backyard is not as efficient as command, but wild card extension NSPipe * newPipe = [NSPipe pipe] provides; NSFileHandle * readHandle = [newPipe fileHandleForReading]; NSDT * INDATA = NIL; NSString * returnValue = Zero; NSTask * unixTask = [[NSTask alloc] init]; [Unixetset setstadindupt: newpip]; [Unixetsk seattlepoint: @ "/ bin / csH"]; [Unixetset algates: [nsarray arrayWithObjects: @ "-c", command, zero]]; [Unixtack launch]; [Unixtask waitunetext]; Int Status = [UNIX Task Termination Status]; While ((inData = [readHandle availableData]) & amp; amp; amp; amp; inData Length]} {returnValue = [[NSString alloc] initWithData: InData encoding: [NSString defaultCStringEncoding]]; ReturnValue = [Return Value SubstringTound: [Return Value Length] -1]; NSLog (@ "% @", returnValue); } Return return value; }  

Comments