• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string


  • Subject: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
  • From: Chris Suter <email@hidden>
  • Date: Tue, 28 Aug 2007 08:42:10 +1000

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.

It doesn't sound like you've looked at the source code for lsof. lsof definitely is a good example of where you should be parsing its output rather than implementing it yourself although it's less important if you only want it to work on one particular version of OS X.


Part of the problem with lsof is that it depends upon internal kernel memory structures which change depending upon kernel version. The 10.4.9 version of lsof will not work on 10.3 for example. By parsing the output of lsof (which does have specific options to help in this regard) you will be able to have something that works on future versions of OS X.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: Gonzalo Castro <email@hidden>)
 >Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: "Shawn Erickson" <email@hidden>)
 >Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: Rosyna <email@hidden>)
 >Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: Rosyna <email@hidden>)
 >Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: Alastair Houghton <email@hidden>)
 >Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string (From: Rosyna <email@hidden>)

  • Prev by Date: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
  • Next by Date: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
  • Previous by thread: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
  • Next by thread: Re: NSTask setStandardOutput: then stringWithContentsOfFile gives empty string
  • Index(es):
    • Date
    • Thread