Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
- Subject: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
- From: Alastair Houghton <email@hidden>
- Date: Mon, 27 Aug 2007 23:10:15 +0100
On 27 Aug 2007, at 22:24, Rosyna wrote:
In fact, parsing tool output is very, very bad and should never be
done.
Perhaps that's taking things too far.
A better (and eminently defensible) position would be to say that
*if* you choose to parse command line tools' output, you should:
1. Be liberal in what you accept. That way you're less likely to
break in future.
2. Accept that at some point you may need to do some work to fix your
program.
A good example of a tool whose output you *should* be parsing rather
than trying to emulate its (horrific) workings is "lsof". Parsing
the output of lsof is a whole lot more likely to continue working in
the future than trying to do what it does.
There's no need to parse the output of the "ps" command, ever,
anyway. You can get all of the information you require using other
APIs. If you actually need BSD layer information, use sysctl() (see
man 3 sysctl... you're interested in KERN_PROC). Chances are,
however, that you actually want a list of user-visible applications
or something, which means you're very likely better off using
NSWorkspace or Process Manager.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden