Re: Using NSPipe to get system command output

2012-08-13 Thread Ken Thomases
On Aug 13, 2012, at 6:52 PM, Andy Lee wrote: > You're very welcome. Although I wonder if you could simply replace the > do-while loop with a call to NSTask's waitUntilExit method. You can't unless you issue a -read..InBackgroundAndNotify method on the output file handle. Otherwise, if you're n

Re: Using NSPipe to get system command output

2012-08-13 Thread Kyle Sluder
On Mon, Aug 13, 2012, at 04:38 PM, Ken Thomases wrote: > On Aug 13, 2012, at 5:42 PM, Kyle Sluder wrote: > > > On Mon, Aug 13, 2012, at 02:17 PM, Charlie Dickman wrote: > >> I'm trying to get the output from a vm_stat command using the following > >> code. My app hangs in the [vmRead availableData

Re: Using NSPipe to get system command output

2012-08-13 Thread Andy Lee
You're very welcome. Although I wonder if you could simply replace the do-while loop with a call to NSTask's waitUntilExit method. --Andy On Aug 13, 2012, at 7:42 PM, Charlie Dickman <3tothe...@comcast.net> wrote: > Andy, > > THANK YOU SO MUCH!! > > I am glad my inquiry spawned some interest

Re: Using NSPipe to get system command output

2012-08-13 Thread Charlie Dickman
Andy, THANK YOU SO MUCH!! I am glad my inquiry spawned some interest but you have taught me how to fish ;^) Thanks again On Aug 13, 2012, at 7:27 PM, Andy Lee wrote: > Apple seems to have pulled the ancient "Moriarity" example which demonstrates > basic use of NSTask, but my cleanup of it sh

Re: Using NSPipe to get system command output

2012-08-13 Thread Ken Thomases
On Aug 13, 2012, at 5:42 PM, Kyle Sluder wrote: > On Mon, Aug 13, 2012, at 02:17 PM, Charlie Dickman wrote: >> I'm trying to get the output from a vm_stat command using the following >> code. My app hangs in the [vmRead availableData] call as it should if >> there is no data available but it never

Re: Using NSPipe to get system command output

2012-08-13 Thread Charlie Dickman
So why doesn't it work??? On Aug 13, 2012, at 7:08 PM, Ken Thomases wrote: > On Aug 13, 2012, at 5:09 PM, Jens Alfke wrote: > >> On Aug 13, 2012, at 2:17 PM, Charlie Dickman <3tothe...@comcast.net> wrote: >> >>> int vmDataLength = 0; >>> do { >>> vmData = [vmRead availableDa

Re: Using NSPipe to get system command output

2012-08-13 Thread Charlie Dickman
This is just test code to see if I can actually get the vm_stat data. It is run only under the debugger 1 or 2 steps at a time. When I have the concept down I will modify it. No, I actually mean != 0, see below - it is the description of how reading available data from a NSFileHandleForReading.

Re: Using NSPipe to get system command output

2012-08-13 Thread Andy Lee
Apple seems to have pulled the ancient "Moriarity" example which demonstrates basic use of NSTask, but my cleanup of it should still work. --Andy On Aug 13, 2012, at 6:42 PM, Kyle Sluder wrote: > On Mon, Aug 13, 2012, at 02:17 PM, Charlie Dickman wrote: >>

Re: Using NSPipe to get system command output

2012-08-13 Thread Ken Thomases
On Aug 13, 2012, at 5:09 PM, Jens Alfke wrote: > On Aug 13, 2012, at 2:17 PM, Charlie Dickman <3tothe...@comcast.net> wrote: > >> int vmDataLength = 0; >> do { >> vmData = [vmRead availableData]; >> vmDataLength = [vmData length]; >> } while (vmDataLength

Re: Using NSPipe to get system command output

2012-08-13 Thread Kyle Sluder
On Mon, Aug 13, 2012, at 02:17 PM, Charlie Dickman wrote: > I'm trying to get the output from a vm_stat command using the following > code. My app hangs in the [vmRead availableData] call as it should if > there is no data available but it never comes back. What am I doing > wrong? I have searched

Re: Using NSPipe to get system command output

2012-08-13 Thread Jens Alfke
On Aug 13, 2012, at 2:17 PM, Charlie Dickman <3tothe...@comcast.net> wrote: > int vmDataLength = 0; > do { > vmData = [vmRead availableData]; > vmDataLength = [vmData length]; > } while (vmDataLength != 0); Don't you mean "== 0" on the final line? Al

Using NSPipe to get system command output

2012-08-13 Thread Charlie Dickman
I'm trying to get the output from a vm_stat command using the following code. My app hangs in the [vmRead availableData] call as it should if there is no data available but it never comes back. What am I doing wrong? I have searched through the sample code on apples developer site with no luck.