Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to run NSTask but getting an error
    primarykey
    data
    text
    <p>I have a standalone (3rd party) app that I'm trying to launch using a command "kick". I've setup my ~/.bash_profile and /etc/bashrc files so that I can type kick [command] into a terminal window and it works perfectly. So I'm assuming that I have everything setup correctly.</p> <p>The problem comes when I try and use NSTask.</p> <p>Essentially what I'm doing is creating two mutable arrays, kickBuild and kickOut. One to assemble the command (it's a string of flags) and one to use with NSTask. I take kickBuild and convert it to a string separated by spaces, then add that as an object into the second array.</p> <p>So my command should look something like <strong>"kick -i /path/to/input/file.ext -as 2 -g 2.2"</strong> etc. And if I type this into a terminal window it works great.</p> <pre><code>kickBuild = [[NSMutableArray alloc] initWithCapacity:100]; kickOut = [[NSMutableArray alloc] initWithCapacity:2]; // Thinking that this should be "kick" and then "-i /path/to/input/file.ext -as 2 -g 2.2" kickPath = [kickLocationTextField stringValue]; // This is just the path to my kick executable. NOT /bin/sh. Is that correct? NSString *tempKick = [kickBuild componentsJoinedByString: @" "]; [kickOut addObject:tempKick]; [NSTask launchedTaskWithLaunchPath:kickPath arguments:kickOut]; </code></pre> <p>When I build my app and run this code, I get this error…</p> <p><strong>dyld: Library not loaded: build/darwin_x86_64/gcc_opt_dynamic/core/libai.dylib</strong></p> <p><strong>Referenced from: /Users/Gene/Kick/Kick-3.3.4.0/bin/kick</strong></p> <p><strong>Reason: image not found</strong></p> <p>This is an NSLog of kickOut… kick -i /Users/Gene/Test_Main.0001.ext -r 960 540 -as 2 -g 2.2 -v 5 -dp</p> <p>Is this something that I'm doing wrong? Or is this an issue with kick?</p> <p>How would I test NSTask with some basic terminal task to make sure that I'm using NSTask correctly?</p> <pre><code>kickBuild = [[NSMutableArray alloc] initWithCapacity:5]; kickOut = [[NSMutableArray alloc] initWithCapacity:2]; kickPath = @"/bin/sh"; [kickBuild addObject:@"-c"]; // Do I need this? [kickBuild addObject:@"ls"]; [kickBuild addObject:@"~/Desktop"]; NSString *tempKick = [kickBuild componentsJoinedByString: @" "]; [kickOut addObject:tempKick]; [NSTask launchedTaskWithLaunchPath:kickPath arguments:kickOut]; </code></pre> <p>If I run this without the @"-c", I get: <strong>/bin/sh: ls ~/Desktop: No such file or directory</strong></p> <p>Any help is appreciated.</p> <p>Thanks a million</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload