Re: NSTask problems.
Re: NSTask problems.
- Subject: Re: NSTask problems.
- From: Greg Hulands <email@hidden>
- Date: Thu, 25 Jul 2002 10:28:55 +1000
If you look on softrak.stepwise.com for CURLHandle by Dan Wood, all this is
already done.
Greg
On 25/7/02 7:06 AM, "Olivier" <email@hidden> allegedly made the following
allegations:
>
Hi,
>
>
I've decided to make my own CURL Handler.
>
>
So begin with the information at cocoadevcentral on wrapping UNIX commands.
>
They tell me to use NSTask so that's what I do.
>
>
After exploring NSTask in the foundation doc,
>
>
I have this code for a test app.
>
>
- (IBAction)loadURL:(id)sender
>
{
>
>
NSTask *cURLSession = [[NSTask alloc] init];
>
NSPipe *shellOutput =[[NSPipe alloc] init];
>
NSFileHandle *fileHandle;
>
NSString *result;
>
>
[cURLSession setLaunchPath:@"/usr/bin/curl"];
>
>
[cURLSession setArguments:[NSArray
>
arrayWithObjects:@"http://ambush.avara.net/index.php",nil]];
>
>
[cURLSession setStandardOutput:shellOutput];
>
[cURLSession setStandardError:shellOutput];
>
fileHandle = [shellOutput fileHandleForReading];
>
>
[cURLSession launch];
>
while([cURLSession isRunning]) // While the proc. is running.
>
{
>
// Do nothing and wait till it's finished...
>
}
>
NSLog(@"Termination Status: %d",[cURLSession terminationStatus]);
>
result=[[NSString alloc] initWithData:[fileHandle readDataToEndOfFile]
>
encoding:NSASCIIStringEncoding];
>
>
[resultField setString:result];
>
>
[result release];
>
[shellOutput release];
>
[cURLSession terminate];
>
[cURLSession release];
>
>
>
>
>
}
>
>
I compile and open the app.
>
I click the button that triggers the IBAction loadURL
>
It loads like in 1 seconds: I'm in heaven.
>
But problems will arrive soon:
>
I decide to see If I can load another url, just for fun
>
I replace http://ambush.avara.net/index.php for http://www.apple.com
>
>
[cURLSession setArguments:[NSArray
>
arrayWithObjects:@"http://www.apple.com",nil]];
>
>
I compile and run the app. The spinning multi colored ball appears. I wait
>
for 2 mins. Nothing loads. So I think " wow apple dot com is down! that's
>
rare!" So I fire up OmniWeb, enter www.apple.com
>
And the page loads. So I think " OH DAMN CURL WONT WORK! "
>
I fire up terminal and type curl http://www.apple.com and it loads like
>
lightning.
>
>
Why cant it load in my app?
>
I use the same CURL in my app and in Terminal what's the problem. I also
>
used the same args..................
>
>
Can someone explain me the problem?
>
>
Thanks
>
>
-jean-olivier
>
_______________________________________________
>
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.
_______________________________________________
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.