0

In objective-c I can do the following:

NSTask* foo = [NSTask alloc]init];
[foo setLaunchPath:@"/usr/bin/open"];

[foo setArguments:[NSArray arrayWithObjects:
                                @"/foo/foobar.app/foobarbinary,
                                nil]];  
// Arguments to the command: the name of the
// Applications directory

[foo launch];
// Run the command

[foo release];

The problem is, if foobarbinary accepts command line arguments, how do I pass them in? :) If I add them to the NSArray, then the shell assumes they are an argument for "open". If I add it to the string, just after foobarbinary, (e.g.: @"foo/foobar.app/foobarbinary -someargument") , then "open" assumes that the name of the file is "foo/foobar.app/foobarbinary -someargument".

So how do I pass an argument to an argument? :S

EDIT. I tried using the --args command in the array. But it seems that foobarbinary doesn't receive the arguments I specify afar the --args. :S Anyone have an example I can look at?

1 Answer 1

1

The open command won't let you do that. If you want to pass arguments to foobarbinary you have to launch it directly.

Sign up to request clarification or add additional context in comments.

1 Comment

It works thanks! It didn't occur to me that you could directly call the binary like that. :S Have to wait two minutes to accept the answer. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.