Received: from stan.ringways.co.uk ([213.38.87.130]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5SEJ2a47812 for ; Thu, 28 Jun 2001 10:19:02 -0400 (EDT) (envelope-from gary.stainburn@ringways.co.uk) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with smtp (Exim 3.13 #1) id 15FcYf-000213-00; Thu, 28 Jun 2001 15:14:13 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: Wayne Johnson Subject: Re: Calling psql from a shell script Date: Thu, 28 Jun 2001 15:18:00 +0100 X-Mailer: KMail [version 1.2] References: <3B3A7DEE.1FE009CE@yahoo.com> In-Reply-To: <3B3A7DEE.1FE009CE@yahoo.com> Cc: "pgsql-interfaces" MIME-Version: 1.0 Message-Id: <01062815180000.21902@gary.ringways.co.uk> Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/82 X-Sequence-Number: 1745 Hi Wayne, There should be no problems using psql in shell scripts. I do it to provide HTML output in some of my early cgi's (although I now use Perl/DBI). I think you can get psql to squirt out the data in kinda CSV format by setting the delimiters that it should use. It's a long time since I did anything like that, but I think it's got something to do with the \pset commands. The way I do it is to pass the commands to psql through STDIN using a heredoc inside the shell script, and then use \o to direct the output and send STDOUT to the bit bucket. Using the -q option to psql to quiet the startup and prompt outputs, you could do it with STDOUT directly. Gary On Thursday 28 June 2001 1:44 am, you wrote: > I am writing some shell scripts that need to access Postgresql. > > What is the best way to select a record and have shell variables set to > the results. > > Is there a way to get psql to output data in quoted CSV? > > TIA. > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://www.postgresql.org/search.mpl -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000