Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jm3X4-0001K2-Tl for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jun 2020 23:01:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jm3WV-0002tI-W0 for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jun 2020 23:00:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jm3WV-0002t6-3F; Thu, 18 Jun 2020 23:00:43 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jm3WR-0004rK-4D; Thu, 18 Jun 2020 23:00:42 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id AA87E4E0; Thu, 18 Jun 2020 19:00:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 18 Jun 2020 19:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=l yM1H3hJErjX7DDdtJyjK73VBwvW/cgbVZqbtCaoIqs=; b=u8XBPgmjIqPCiDjMv UE6k1UtIha5Wy0aPzexd2c//j2uwPh5kkXts5FlFAArGDosYX7cfCwkuEk/5/ViC KzOQTLD9Qw1pX50+SB/AO8BHMu3wVnNIRYJMOqXpNpjhkTkHNKabCq03y7yRZcp3 jG434sxISCnkIv+91wBaOYsLmWNRer/zxlkOTHDJr8Y+m6YnlLE+wlMPo/YUKLcp 0WRIC9IvyOe3seuB0YFC18pazvtpvkzF++qkpTOf3Deaw1ItuN+0Hg4faaeWwDqP m0G9FnHPZtp0TEwiZ7mXEyP6eZLLbOoY0YMmQ2CIOuYGm76U+dvOSfcjYW1KrzF5 xsNLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=lyM1H3hJErjX7DDdtJyjK73VBwvW/cgbVZqbtCaoI qs=; b=X/k7PSKfCOpfKBLWr7eL6ctDs4C6NSZBhKVN2APlEzLJtbR1uxITDJIhz J5AHkXfFfKlEtHLybpyeDwDXuUgot0OGL/RJKFAiw1SJ9Ix4f0kijq3CtS5/rECv cot3z+j4z3XJwukYCOlnfgO5qUCN5pQdG0eLcDoeqIRSPe9IXPwhJAq0NSDS7ped Y00oDk37XCmivJgV8sfUOmDAmyEHchMEsr9QPovfiWlqOvjmegkTkdCDdVM78YYb 3e07Q/lOwQoIV5ZPjkH5yNpFmjqCYe2iLeWYboRGwClP0nJ/JUwHqi4aLNGqQvHK vAWM6E8GvCn2mnduvd+rxS8FoX3jw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejhedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeehvdelledujefhteekueefvddtuedvudekjefgvedu ieduteeijefgudekveevgeenucffohhmrghinheprghmrgiiohhnrgifshdrtghomhdpph hoshhtghhrvghsqhhlrdhorhhgnecukfhppeejhedrudejvddrhedrvdefudenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkh hlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 88DA4328005E; Thu, 18 Jun 2020 19:00:34 -0400 (EDT) Subject: Re: create batch script to import into postgres tables To: Pepe TD Vo , Christopher Browne Cc: Pgsql-admin , Pgsql-general References: <866581879.1147164.1592317256828.ref@mail.yahoo.com> <866581879.1147164.1592317256828@mail.yahoo.com> <1f5f4fd6-ad22-4823-c922-17a021c2c0d7@aklaver.com> <74046808.1129536.1592317823808@mail.yahoo.com> <3625e291-8456-3831-6205-2d73232bcd1e@aklaver.com> <1718146430.1151531.1592319564343@mail.yahoo.com> <1761277119.1163490.1592322138731@mail.yahoo.com> <732982585.145357.1592493607620@mail.yahoo.com> <1814718409.184531.1592498400894@mail.yahoo.com> <4d5841c4-9a6c-0e20-2c05-c21d3d3942df@aklaver.com> <889466258.267016.1592510085000@mail.yahoo.com> From: Adrian Klaver Message-ID: <57eddc72-9278-9e17-3df2-3cd8bb40e82d@aklaver.com> Date: Thu, 18 Jun 2020 16:00:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <889466258.267016.1592510085000@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/18/20 12:54 PM, Pepe TD Vo wrote: >>>psql -d production  -U postgres -c 'select count(*) from cell_per'; > Null display is "NULL". >   count > ------- >     68 > (1 row) > > you can do this once you are in psql. But if you are running from shell > script, it will be an error > > >>What error messages do you get? > > my shell script is: > @echo off > C:\Program Files\PostgreSQL\11\bin\psql -U PSmasteruser  -d PSCIDR -h > hostname.amazonaws.com -p 5432 -c "select count(*) from tableA;" > pause > > the error I have is 'C:\Program' is not recognized as an internal or > external command, operable program or batch file. > > I even surround the path in quotes because of space. > @echo off > cmd /c ""C:\Program Files\PostgreSQL\11\bin\psql" -U PSmasteruser -d > PSCIDR -h hostname.amazonaws.com -p 5432 -c "select count(*) from tableA;" > pause Not sure how quoting works in Windows shell scripts, but pretty sure the above has unbalanced quotes. > > error is: 'C:\Program Files\PostgreSQL\11\bin\psql: illegal option -- u > > when I put -P Password123 (or fully qualified password=Password123) I would recommend spending some time here: https://www.postgresql.org/docs/12/app-psql.html to see what the options are. Hint: -P is not the option for password. > > it gives me another error "pset: unknow option: Password123 > psql: could not set printing parameter "Password123" It is the option for pset as the error message says. > > I can connect from psql shell fine when it prompt hostname, username > (but connect to postgres not to PSmasteruser, PSmasteruser username set > up for aws maintenance postgres database, someone did, not me and the > password is same on both).  Once I'm in psql and I can change to PSCIDR > instance fine and run select count(*) from tableA; > > > > ** > *Bach-Nga > -- Adrian Klaver adrian.klaver@aklaver.com