From CTE@Dal.Ca Thu Jul 6 15:49:49 2000 Received: from Alex2.cte.Dal.Ca (Alex2.cte.Dal.Ca [134.190.17.62]) by hub.org (8.10.1/8.10.1) with ESMTP id e66FnnW76210 for ; Thu, 6 Jul 2000 11:49:49 -0400 (EDT) Received: from ghost (Ghost.cte.Dal.Ca [134.190.17.89]) by Alex2.cte.Dal.Ca (8.9.3/8.9.3) with SMTP id NAA13124 for ; Thu, 6 Jul 2000 13:01:52 -0300 Message-ID: <011001bfe761$e57a3a60$5911be86@cte.Dal.Ca> From: "DalTech - Continuing Technical Education" To: Subject: Running queries from scripts. Date: Thu, 6 Jul 2000 12:50:23 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_010D_01BFE748.C00B70A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Archive-Number: 200007/60 This is a multi-part message in MIME format. ------=_NextPart_000_010D_01BFE748.C00B70A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I was wondering if anyone could help me out with the syntax of running quer= ies from a unix script. psql -c select 'I am a dummy' -d dbname - never seems to work. I've tried= variations on the command line, but to no success. Does the -c option work? Cheers, Christopher Currie __________________________________ Dalhousie: DalTech - CTE Visit our Web site at http://www.cte.dal.ca (902) 494-6079 (800) 565-1179 ------=_NextPart_000_010D_01BFE748.C00B70A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I was wondering if anyone could help me out with the sy= ntax of=20 running queries from a unix script.
 
psql -c select 'I am a dummy' -d dbname  - never s= eems to=20 work.  I've tried variations on the command line, but to no=20 success.
 
Does the -c option work?
 
Cheers,
Christopher Currie

__________________________________
Dalhousie: Da= lTech -=20 CTE
Visit our Web site at http://www.cte.dal.ca
(902)=20 494-6079
(800) 565-1179
------=_NextPart_000_010D_01BFE748.C00B70A0-- From brita@umich.edu Thu Jul 6 15:58:03 2000 Received: from donkeykong.gpcc.itd.umich.edu (smtp@donkeykong.gpcc.itd.umich.edu [141.211.2.163]) by hub.org (8.10.1/8.10.1) with ESMTP id e66Fw3W97451 for ; Thu, 6 Jul 2000 11:58:03 -0400 (EDT) Received: from tempest.gpcc.itd.umich.edu (smtp@tempest.gpcc.itd.umich.edu [141.211.2.155]) by donkeykong.gpcc.itd.umich.edu (8.8.8/4.3-mailhub) with ESMTP id LAA05358; Thu, 6 Jul 2000 11:55:34 -0400 (EDT) Received: from localhost (brita@localhost) by tempest.gpcc.itd.umich.edu (8.8.8/5.1-client) with ESMTP id LAA25255; Thu, 6 Jul 2000 11:58:01 -0400 (EDT) Precedence: first-class Date: Thu, 6 Jul 2000 11:58:00 -0400 (EDT) From: Margarita Barvinok X-Sender: brita@tempest.gpcc.itd.umich.edu To: DalTech - Continuing Technical Education cc: pgsql-sql@postgresql.org Subject: Re: Running queries from scripts. In-Reply-To: <011001bfe761$e57a3a60$5911be86@cte.Dal.Ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200007/61 Hi, It works for me, for example, this way: athens% psql -d template1 -c "select datname from pg_database" datname ----------- template1 postgres biology test (4 rows) Hope this helps, -Rita On Thu, 6 Jul 2000, DalTech - Continuing Technical Education wrote: > I was wondering if anyone could help me out with the syntax of running queries from a unix script. > > psql -c select 'I am a dummy' -d dbname - never seems to work. I've tried variations on the command line, but to no success. > > Does the -c option work? > > Cheers, > Christopher Currie > > __________________________________ > Dalhousie: DalTech - CTE > Visit our Web site at http://www.cte.dal.ca > (902) 494-6079 > (800) 565-1179 > -------------------------------------------------------- Margarita Barvinok University of Michigan System Administrator II Department of Biology brita@umich.edu --------------------------------------------------------- From CTE@Dal.Ca Thu Jul 6 16:15:47 2000 Received: from Alex2.cte.Dal.Ca (Alex2.cte.Dal.Ca [134.190.17.62]) by hub.org (8.10.1/8.10.1) with ESMTP id e66GFlW43359 for ; Thu, 6 Jul 2000 12:15:47 -0400 (EDT) Received: from ghost (Ghost.cte.Dal.Ca [134.190.17.89]) by Alex2.cte.Dal.Ca (8.9.3/8.9.3) with SMTP id NAA13351; Thu, 6 Jul 2000 13:27:49 -0300 Message-ID: <013c01bfe765$8304b460$5911be86@cte.Dal.Ca> From: "DalTech - Continuing Technical Education" To: "Margarita Barvinok" Cc: References: Subject: Re: Running queries from scripts. Date: Thu, 6 Jul 2000 13:16:16 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Archive-Number: 200007/62 > It works for me, for example, this way: > athens% psql -d template1 -c "select datname from pg_database" Thanks, I feel a little sheepish at not trying it with quotes around the query, but the manuals don't mention that you have to enclose the query in quotes when you use the -c option. -Christopher Currie