• 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
NSTask problems.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask problems.


  • Subject: NSTask problems.
  • From: Olivier <email@hidden>
  • Date: Wed, 24 Jul 2002 17:06:42 -0400

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.

  • Follow-Ups:
    • Re: NSTask problems.
      • From: Ingvar Nedrebo <email@hidden>
    • Re: NSTask problems.
      • From: Greg Hulands <email@hidden>
    • Re: NSTask problems.
      • From: Nicholas Riley <email@hidden>
  • Prev by Date: Re: PackageMaker design doc published
  • Next by Date: Re: Design Application
  • Previous by thread: Re: off-screen imageview drawing
  • Next by thread: Re: NSTask problems.
  • Index(es):
    • Date
    • Thread