Re: NSTask not using arguments?
Re: NSTask not using arguments?
- Subject: Re: NSTask not using arguments?
- From: Sherm Pendley <email@hidden>
- Date: Thu, 24 Feb 2005 21:14:50 -0500
On Feb 24, 2005, at 6:58 PM, James McConnell wrote:
clarification (as I'm not able to test this), I would have to provide
the
absolute path to the executable as it resides in my
/Resources/Binaries/bin
folder in my Contents folder of my app package, correct? I'm fairly
certain, but I ask simply for clarification. And this of course would
be
achieved by using [[NSBundle mainBundle] resourcePath] and appending
the
correct subpath with "stringAppendingByString".
Right. The launch path would be "/bin/sh". The first argument "-c", and
the second the complete command you wanted to execute. It would be a
really good idea to include fully-qualified path names.
As Andy pointed out, it would be a good idea to allow for spaces and
other characters that might appear in file names. You could do that
yourself, of course - but why reinvent the wheel? :-) Since you're
using a shell command anyway, it's easier to just use find and xargs:
find /path/to/files -name '*.ext' -print0 | xargs -0 /path/to/command
Find will list the file names it finds, with NULs as separators. Xargs,
with the -0 switch, expects a list of NUL-separated strings as its
input, and will provide those strings as arguments to the command
specified.
I will need, however, to do the infamous "output from NSTask to
NSTextView",
Another shell trick - if you want to both read the output from the
command (so you can display it), and store it to a file, you can add
the "tee" utility to the chain:
find /path/to/files -name '*.ext' -print0 | xargs -0 /path/to/command |
tee /path/to/outfile
As its name implies, tee takes its input - which will be the output
piped from "command" - and writes it to the specified file, as well as
echoing it to its stdout.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden