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"];
>       
>    NSArray *arguments;
>    arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep 
> /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil];
>       // arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k", @"| 
> /usr/bin/grep /dev/ | /usr/bin/awk '{print $1 '\t' $4 '\t' $5 '\t' 
> $6;}'",nil];

You have to pass each word as a separate string:

arrayWithObjects: @"-c", @"/bin/df", @"-k", @"|", @"/usr/bin/grep", etc.

--
Rick Genter
rick.gen...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to