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: Rosyna <email@hidden>
- Date: Mon, 27 Aug 2007 15:21:13 -0700
Ack, at 8/27/07, Alastair Houghton said:
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.
I don't think it's taking it far enough.
The only exception in parsing output is if you
wrote your *own* tool that needs to run as
another user. But even then, using IPC is a far,
far better solution.
2. Accept that at some point you may need to do some work to fix your program.
Or you could just use the proper APIs that won't break in the future.
And when the output of a command line tool
(especially a complex one like ps) changes, you
may not be able to foresee the changes and bad
thingsĀ will happen.
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.
lsof is not a good example. If I needed to do
what lsof did, I'd take it from the source code
of lsof
(http://www.opensource.apple.com/darwinsource/10.4.9.ppc/lsof-28/lsof/)
and adapt it to my specific needs. lsof has a lot
of options that may not be necessary to implement
for your needs.
And lsof hails from 1994. It's old, so it must be bad.
--
Sincerely,
Rosyna Keller
Technical Support/Carbon troll/Always needs a hug
Unsanity: Unsane Tools for Insanely Great People
It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
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