Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atk26-00080C-Rq for pgsql-sql@arkaria.postgresql.org; Fri, 22 Apr 2016 22:58:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1atk26-0006Dt-Dx for pgsql-sql@arkaria.postgresql.org; Fri, 22 Apr 2016 22:58:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1atk25-0006C9-EJ for pgsql-sql@postgresql.org; Fri, 22 Apr 2016 22:58:41 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1atk21-0007td-UO for pgsql-sql@postgresql.org; Fri, 22 Apr 2016 22:58:41 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 96179282A4 for ; Fri, 22 Apr 2016 18:58:36 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Fri, 22 Apr 2016 18:58:36 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=M91rdyIlYO6xrelJNWlO1Hidkuk=; b=CxdG2C 3HiLopPLHZ76WEoMYhEZvB67u7KIRsQRl/d+HkCgJiK7C3Cowx2hVZ/ukd/VGIg6 XuvBYdOa2nyXqhQlgn/72rB5U3r+5Jyam0t5j3x2/Ju8JY3Myu5uENNO/rVUwE/1 NxehP/TEeVKWFXs90qajzcgWGXNuenwmalYBc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=M91rdyIlYO6xrel JNWlO1Hidkuk=; b=rdzPGQO9mCoiOFZN2HMOlsOezZN6AYyvIqJlvt47gPyaUkN zlewNv86OLesxY1Bet9BSIOv9oXhVQuQA8U8q+TpUx0EgYsn1+WnQry1DAiV5o3C glBsqo76mMw+1b4EsRpYiCSgrHn/OeJApNQZRWJnyE1dvokXDnz7OPKqAlqA= X-Sasl-enc: kY0nSaX8p1s6sUZvw6My7qiVWSNCCq+K4E5PRv7zdNtV 1461365916 Received: from [192.168.1.2] (174-24-160-10.tukw.qwest.net [174.24.160.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 07E28680100; Fri, 22 Apr 2016 18:58:35 -0400 (EDT) Subject: Re: How to get pgsql to echo commands in a command file To: Michael Moore , postgres list References: From: Adrian Klaver Message-ID: <4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com> Date: Fri, 22 Apr 2016 15:58:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 04/22/2016 03:50 PM, Michael Moore wrote: > I log into pgsql and then type: > \i test.sql > > test.sql contains a single SELECT command and when I run that file I see > the result of the select command.. The problem is, I also want to see > the SELECT command itself. > > I've tried > /echo > /qecho > and a lot of other commands, but nothing works. http://www.postgresql.org/docs/9.5/interactive/app-psql.html " ECHO If set to all, all nonempty input lines are printed to standard output as they are read. (This does not apply to lines read interactively.) To select this behavior on program start-up, use the switch -a. If set to queries, psql prints each query to standard output as it is sent to the server. The switch for this is -e. If set to errors, then only failed queries are displayed on standard error output. The switch for this is -b. If unset, or if set to none (or any other value than those above) then no queries are displayed. " aklaver@panda:~> cat psql_test.sql select * from a ; aklaver@panda:~> psql -a -d test -U postgres -h localhost psql (9.4.6) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. test=# \i psql_test.sql select * from a ; id | v1 | v2 | v3 ----+----+----+---- 1 | 2 | 3 | 4 2 | 2 | 3 | 4 (2 rows) > > What do I need to do in order to see the commands in test.sql as well as > the output of those commands on my pgsql window? > > I'm running on Windows 7 if that matters. > > TIA, > Mike -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql