Solved!! NSLog issue with NSTask Bash commands Re: Solved BUT How to get NSLog back - Re: NSTask and piped commands -

2010-05-19 Thread René v Amerongen
Op 19 mei 2010, om 11:44 heeft René v Amerongen het volgende geschreven: >> > > Because I didn't see any result, I noticed that this happened only when I use > /bin/sh -c. > > My code was just a short piece in main as test bed, and did trust my NSLog > output which was ok and visible in the x

Solved BUT How to get NSLog back - Re: NSTask and piped commands -

2010-05-19 Thread René v Amerongen
Op 19 mei 2010, om 03:37 heeft Greg Guerin het volgende geschreven: > appledev wrote: > >>arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep >> /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil]; > > > Your awk syntax is somewhere between quirky and wrong. Since you

Re: NSTask and piped commands

2010-05-18 Thread Greg Guerin
appledev wrote: arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| / usr/bin/grep /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil]; Your awk syntax is somewhere between quirky and wrong. Since you didn't mention what the problem was, I will assume the output you want is not

Re: NSTask and piped commands

2010-05-18 Thread René v Amerongen
Op 18 mei 2010, om 21:48 heeft Stephen J. Butler het volgende geschreven: >> > > Depending on what information you need, I'd use [NSWorkspace > mountedLocalVolumePaths] and then [NSFileManager > attributesOfFileSystemForPath:error:]. > Didn't have NSWorkspace some bugs with giving the right in

Re: NSTask and piped commands

2010-05-18 Thread Jens Alfke
On May 18, 2010, at 3:04 PM, René v Amerongen wrote: > Maybe just an imagination from me, but it looks slow all that moving of > results to the next task. But that’s exactly what the shell does! The “|” operator spawns a process for each side and hooks the output of the first to the input of t

Re: NSTask and piped commands

2010-05-18 Thread René v Amerongen
Thanks for this. Your right about this idea. I will check it out. René Op 18 mei 2010, om 22:34 heeft Alastair Houghton het volgende geschreven: > On 18 May 2010, at 20:33, appledev wrote: > >> [task launch]; >> >> [task waitUntilExit]; >> >> NSData *data; >> result = [file read

Re: NSTask and piped commands

2010-05-18 Thread René v Amerongen
Sorry for the late reaction. I did check every ten minutes Cocoabuilder and sometimes my mail, but I see that there where all ready replies before I got my own posting. Op 18 mei 2010, om 22:13 heeft Jens Alfke het volgende geschreven: >> I dont want to use a call to a bash script, because of

Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 21:35, Jens Alfke wrote: > On May 18, 2010, at 1:27 PM, Alastair Houghton wrote: > >> Something like the following should work, right? > > That looks right; but you’re proving my point that it’s easier just to do the > filtering in native code :) Well, there is that too :-)

Re: NSTask and piped commands

2010-05-18 Thread Jens Alfke
On May 18, 2010, at 1:27 PM, Alastair Houghton wrote: > Something like the following should work, right? That looks right; but you’re proving my point that it’s easier just to do the filtering in native code :) —Jens___ Cocoa-dev mailing list (Cocoa

Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 20:33, appledev wrote: >[task launch]; > >[task waitUntilExit]; > >NSData *data; >result = [file readDataToEndOfFile]; This part is not safe. If the tasks output enough data to fill the pipe buffer (which may be of whatever size the kernel chooses to m

Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 21:13, Jens Alfke wrote: > > On May 18, 2010, at 12:33 PM, appledev wrote: > >> I dont want to use a call to a bash script, because of sneaking in bad >> commands. > > As others said, it’s not a problem here because the command line is entirely > hardcoded. > > If you want

Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 20:48, Stephen J. Butler wrote: > On Tue, May 18, 2010 at 2:33 PM, appledev wrote: >> I dont want to use a call to a bash script, because of sneaking in bad >> commands. >> But how should I handle this? > > That's only a real concern when you put user supplied data into the >

Re: NSTask and piped commands

2010-05-18 Thread Jens Alfke
On May 18, 2010, at 12:33 PM, appledev wrote: > I dont want to use a call to a bash script, because of sneaking in bad > commands. As others said, it’s not a problem here because the command line is entirely hardcoded. If you wanted to avoid using a shell, you’d have to start three separate

Re: NSTask and piped commands

2010-05-18 Thread Stephen J. Butler
On Tue, May 18, 2010 at 2:37 PM, Rick Genter wrote: > On May 18, 2010, at 12:33 PM, appledev wrote: > >>    NSArray *arguments; >>    arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep >> /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil]; >>       // arguments = [NSArray ar

Re: NSTask and piped commands

2010-05-18 Thread Stephen J. Butler
On Tue, May 18, 2010 at 2:33 PM, appledev wrote: > I dont want to use a call to a bash script, because of sneaking in bad > commands. > But how should I handle this? That's only a real concern when you put user supplied data into the command you're running. But I don't see you doing that here...

Re: NSTask and piped commands

2010-05-18 Thread Rick Genter
On May 18, 2010, at 12:33 PM, appledev wrote: > I have to run the following and similar commands using NSTask. > > df -k | grep /dev/ |awk '{print $1 "\t" $4 "\t" $5 "\t" $6;}' > > I got so far. > > NSTask *task; >task = [[NSTask alloc] init]; >[task setLaunchPath: @"/bin/sh"]; >