external application argument


macNewbie

New Member
Joined
Mar 16, 2006
Messages
1
Reaction score
0
Hi,
I'm building cocoa application which launch external command line application.
The command line requires file as an input and output as a file as well.
In the command line will be: nfbtrans <inputFile.txt >outputFile.txt which means take input from inputFile and store the result in outputFile. It works fine.
In cocoa, part of my program is as follows:

NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/local/bin/nfbtrans"];

NSArray *arg;
NSString *inFileArgument = @"</inputFile.txt";
NSString *outFileArgument = @">/out.txt";
arg = [NSArray arrayWithObjects:inFileArgument,outFileArgument, nil];
[task setArguments:arg];
[task launch];

The command line application launched but it said that the inputFile.txt doesn't exist. However, when I check in the directory, the file does exist. I suspect that it has problem with "<" character. Is that any special way to handle special characters arguments?

Thank you in advance.
 
Ad

Advertisements

Ric

New Member
Joined
May 14, 2004
Messages
4,260
Reaction score
4
Hi there and welcome !

first question...do you get this error when doing a 'Build and Run' in Xcode ?

Have you tried doing a Build and then quitting Xcode and Running the 'Built App' this may work...when looking at the 'Built' App in the Finder control click on it to see if the files are there...

regards

Ric
 
Ad

Advertisements

Kaveman

New Member
Joined
Nov 26, 2010
Messages
3,558
Reaction score
49
I think the @">" and the @"/inputFile" need to be separate things in the NSArray. Ones a switch the other a FilePath.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top