• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Executing A Shell Script...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initWithData:[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.

  • Prev by Date: Console messages at PB startup
  • Next by Date: Re: Executing A Shell Script...
  • Previous by thread: Re: Executing A Shell Script...
  • Next by thread: Console messages at PB startup
  • Index(es):
    • Date
    • Thread