Re: Executing A Shell Script...
Re: Executing A Shell Script...
- Subject: Re: Executing A Shell Script...
- From: Graeme Nattress <email@hidden>
- Date: Fri, 30 Aug 2002 10:10:56 -0400
*This message was transferred with a trial version of CommuniGate(tm) Pro*
The answer is NSTask, which I have used successfully to get a Cocoa
interface run a TCL shell script. It's probably not the best code,
but here is how I call my TCL script
- (void)Execute:(NSString *)parameterString
{
NSLog(@"count %i",[slaves count]);
NSPipe *fromPipe;
NSString *path =0;
NSTask *ribhacker;
NSString *str;
NSFileHandle *fromRibhack;
fromPipe = [NSPipe pipe];
fromRibhack = [fromPipe fileHandleForReading];
[FeedbackTextview setString:parameterString];
[FeedbackTextview appendString:@"\r"];
[FeedbackTextview appendString:@"RibHacker is Running\r"];
ribhacker = [[NSTask alloc] init];
path = [ [NSBundle mainBundle]
pathForAuxiliaryExecutable:@"Contents/Resources/ribhack.tcl"];
//parameterString = [NSString stringWithFormat:@"%@", pathRibhack];
[ribhacker setLaunchPath:path];
[ribhacker setArguments:[NSArray arrayWithObject:parameterString]];
[ribhacker setStandardOutput:fromPipe];
[ribhacker launch];
str = [ [NSString alloc] initWith
Data:[fromRibhack
readDataToEndOfFile] encoding:NSASCIIStringEncoding];
[FeedbackTextview appendString:str];
[str release];
[ribhacker release];
[FeedbackTextview scrollRangeToVisible:NSMakeRange([
[FeedbackTextview textStorage] length],0)];
}
I put the TCL script in with the cocoa application bundle so that all
the user see and has to install is the application itself.
Graeme
--
--
Graeme Nattress: Vice President R&D www.noitaminanimation.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.