• 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
Launching Terminal Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Launching Terminal Application


  • Subject: Launching Terminal Application
  • From: mw <email@hidden>
  • Date: Fri, 29 Nov 2002 23:49:33 -0500

Hey all,

I based this little bit of "sample code" off of an Apple code example in the
dev docs. It is just supposed to load up 'top' from the command-line, and
then pipe the output back into the cocoa program and display it in an
NSTextView. But it doesn't work. I get an error that says "Error opening
terminal: unknown." I have no idea what I am doing wrong. Here is the code.

#import "AppController.h"
#import <Foundation/Foundation.h>

@implementation AppController

- (IBAction)runPipe:(id)sender
{
NSTask *taskCalledTop = [[NSTask alloc] init];
NSPipe *readPipeToTop = [NSPipe pipe];
NSFileHandle *readHandleToTop = [readPipeToTop fileHandleForReading];
NSData *dataFromTop = nil;

[taskCalledTop setStandardOutput:readPipeToTop];
[taskCalledTop setLaunchPath:@"/usr/bin/top"];
[taskCalledTop setArguments:[NSArray arrayWithObject:@"ln0"]];
[taskCalledTop launch];
dataFromTop = [readHandleToTop availableData];
[self dataToTextView:dataFromTop];

[taskCalledTop release];
}

- (void)dataToTextView:(NSData *)data
{
[textView insertText:data];
}

@end

Btw, the error is being shown after the line [taskCalledTop launch] is
executed. Any ideas?

TIA, mw
_______________________________________________
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.

  • Follow-Ups:
    • Re: Launching Terminal Application
      • From: Bryan Blackburn <email@hidden>
  • Prev by Date: Re: metakit
  • Next by Date: Re: Launching Terminal Application
  • Previous by thread: Re: metakit
  • Next by thread: Re: Launching Terminal Application
  • Index(es):
    • Date
    • Thread