OK, I am making this app which will be a GUI wrapped command. I started out using the Tutorial at
CocoaDevCentral for wgetWrapper.
I got through that OK, but now I'm modifying it to make it work like I want. I stripped the UI down to just a text box and a button. I only have the wgetWrapper.m and wgetWrapper.h files for code (that I've touched, anyway).
Here is the code that I'm at right now. This is from my wgetWrapper.m file.
Code:
#import "wgetWrapper.h"
@implementation wgetWrapper
- (IBAction)download :(id)sender
{
[downloadButton setTitle:@"Running..."];
[downloadButton setEnabled:NO];
wget = [[NSTask alloc] init];
[wget setLaunchPath:@"/usr/bin/wget"];
[wget setArguments:[NSArray arrayWithObjects:@"-q",@"-O",@"/dev/stdout",[url stringValue],nil]];
[wget launch];
}
- (id)init {
self = [super init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(finishedDownload :)
name:NSTaskDidTerminateNotification
object:nil];
wget = nil; // This is a good time to initialize the pointer
return self;
}
- (void)finishedDownload :(NSNotification *)aNotification {
[downloadButton setTitle:@"Download"];
[downloadButton setEnabled:YES];
[wget release]; // Don't forget to clean up memory
wget=nil; // Just in case...
}
@end
As it is, this code works. It returns the HTML of a web page typed into the text field. Right now, it only returns it into the "Run" tab, but it at least works. This next code is just an excerpt from the one above. I'm guessing this is where I need to focus my energy.
Code:
wget = [[NSTask alloc] init];
[wget setLaunchPath:@"/usr/bin/wget"];
[wget setArguments:[NSArray arrayWithObjects:@"-q",@"-O",@"/dev/stdout",[url stringValue],nil]];
[wget launch];
And just for good measure, here is my wgetWrapper.h code.
Code:
#import <Cocoa/Cocoa.h>
@interface wgetWrapper : NSObject
{
IBOutlet id downloadButton;
IBOutlet id url;
IBOutlet id window;
}
- (IBAction)download :(id)sender;
NSTask *wget;
@end
OK, firstly, thanks for reading all that. Secondly, here's my problem.
I want to pipe the result to grep so I can filter it down. From there I plan to pipe it again, but if I learn to do it for the first one, the second should be fairly easy.
I can't figure out how to use NSPipe. What can I do to get started? I've tried everything I can think of (using code from Apple's site and code from these forums that I searched out) and I haven't come up with a working way.
On a slightly different note, I want to make it return that HTML to a text box (or some static text, whatever) in the UI. I'm not sure how to do that either.
I apologize for my ignorance. TIA for any and all help.
[edit: smiles should be off by default in [code] text.];
------------------
[This message has been edited by Xeo (edited 05-09-2001).]