• 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: Problem with arguments of an NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with arguments of an NSTask


  • Subject: Re: Problem with arguments of an NSTask
  • From: Chris Ridd <email@hidden>
  • Date: Tue, 29 Oct 2002 12:17:43 +0000

On 29/10/02 12:02 pm, Arthur VIGAN <email@hidden> wrote:

> Hi,
>
> I would like to use arguments to launch a command line application
> using an NSTask (the SETI@home client), but I get some troubles.
> Everything works just fine when I laucnh the task without any argument,
> but the following code doesn't work and I don't see where the mistake
> is:
>
> NSArray *arguments = [NSArray arrayWithObject:@"-nice 19"];
> NSTask *setiTask = [[NSTask alloc] init];
>
> [setiTask setArguments:arguments];
>
> //there is some other stuff here, but this is not the problem
>
> NSLog(@" --> Running SETI...");
> [setiTask launch];
>
> The code is good, but when I launch my application, I get the following
> message on the console:
>
> bad arg: -nice 19
> options:
> -version show version info
> -login log in
> -countries show list of country codes
> -nice N set priority to N
> ...
>
> so "-nice 19" seems to be a bad argument whereas the options indicates
> that the syntax is good. Where is the problem? Does it come from my
> code?

Your code's at fault. When you enter the command "foo -nice 19" on the
command line, this ends up passing three arguments to foo (arg 0="foo", arg
1="-nice" and arg 2="19". Some systems pass arg 3=NULL.)

You need to construct an array of two strings instead of a single string.

Cheers,

Chris
_______________________________________________
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.

References: 
 >Problem with arguments of an NSTask (From: Arthur VIGAN <email@hidden>)

  • Prev by Date: Re: Problem with arguments of an NSTask
  • Next by Date: Re: Problem with arguments of an NSTask
  • Previous by thread: Re: Problem with arguments of an NSTask
  • Next by thread: Re: Problem with arguments of an NSTask
  • Index(es):
    • Date
    • Thread