X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CEFAD5E46CF for ; Thu, 12 Aug 2004 15:58:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04192-07 for ; Thu, 12 Aug 2004 18:58:47 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 4E0645E46D9 for ; Thu, 12 Aug 2004 15:58:45 -0300 (ADT) Received: from 192.168.1.80 (unknown [66.207.200.34]) by www.postgresql.com (Postfix) with ESMTP id E22855A10ED for ; Thu, 12 Aug 2004 12:56:07 -0300 (ADT) Received: by 192.168.1.80 (Postfix, from userid 500) id EBF556A57A; Thu, 12 Aug 2004 11:53:09 -0400 (EDT) Subject: Re: Sending errors from psql to error file From: Devin Whalen Reply-To: devin@synapticvision.com To: olly@lfix.co.uk Cc: pgsql-sql@postgresql.org In-Reply-To: <1092323361.11184.34.camel@braydb> References: <1092320416.23985.24.camel@192.168.1.80> <1092322233.11188.30.camel@braydb> <1092322881.23985.38.camel@192.168.1.80> <1092323361.11184.34.camel@braydb> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Synaptic Vision Message-Id: <1092325989.23985.52.camel@192.168.1.80> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6-2mdk Date: Thu, 12 Aug 2004 11:53:09 -0400 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/118 X-Sequence-Number: 18615 On Thu, 2004-08-12 at 11:09, Oliver Elphick wrote: > On Thu, 2004-08-12 at 16:01, Devin Whalen wrote: > > > zcat cli_postDataInserts.sql.gz | > > > psql -d cli_post -U system --echo-queries -f - >trace.file 2>&1 > > > > Just a few questions about your command. I tried it with one sql > > statement that I know doesn't work and the error went into the right > > file. However, I would like to know WHY it works...hope you don't mind > > shedding some light on it :). Specifically, the - >trace.file 2>&1 > > part. I know...well actually think, that the > is redirecting the ouput to the trace.file. But what the hell is 2>&1 doing?? > > Also, the - ...it kinda just looks like a stray dash to me....although I know it must be doing something ;). > > Will this put all output? Or just the errors. > > ">" redirects standard output > "2>" redirects standard error > > Your command did not redirect standard error, so the errors didn't get > to grep > > The syntax for -f is "-f filename"; the filename "-" means standard > input. (Check the man page for psql!) > > > Oliver Thanks for you explanations. They are a big help. Now that I understand it better I can modify it to suit my needs. I really only want the errors because if I keep track of all the inserts then the file will be too big. So I just have to use 2>, or rather 2>> so I can append to the file. The syntax for -f is "-f filename"; the filename "-" means standard > input. (Check the man page for psql!) I swear I read it like 15 times and I guess I just scanned over that part every time!! :) Later -- Devin Whalen Programmer Synaptic Vision Inc Phone-(416) 539-0801 Fax- (416) 539-8280 1179A King St. West Toronto, Ontario Suite 309 M6K 3C5 Home-(416) 653-3982