Re: capture console output
Re: capture console output
- Subject: Re: capture console output
- From: Billy Flatman <email@hidden>
- Date: Thu, 22 Apr 2010 11:23:40 +0100
Hi Dave,
Thanks for that, just what I was looking for.
Cheers,
Billy.
On 22 Apr 2010, at 11:04, Dave Keck wrote:
>> FILE *file = popen("sqlite3 test.db .tables","r");
>>
>> However, I've not been able to read the information from the returned file.
>
> What exactly isn't working? Maybe this helps:
>
> NSString *fullPathToDatabase = @"/Users/dave/test.db";
> NSTask *sqliteTask = [[NSTask alloc] init];
> NSPipe *readPipe = [NSPipe pipe];
>
> [sqliteTask setLaunchPath: @"/usr/bin/sqlite3"];
> [sqliteTask setArguments: [NSArray arrayWithObjects:
> fullPathToDatabase, @".tables", nil]];
> [sqliteTask setStandardOutput: readPipe];
> [sqliteTask launch];
>
> NSLog(@"sqlite wisdom: %@", [[[NSString alloc] initWithData:
> [[readPipe fileHandleForReading] readDataToEndOfFile]
> encoding: NSUTF8StringEncoding] autorelease]);
Billy Flatman
email@hidden
_______________________________________________
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