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 1jm46X-0002NQ-Qq for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jun 2020 23:37:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jm46W-0001gN-QL for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jun 2020 23:37:56 +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 1jm46W-0001gF-5s for pgsql-admin@lists.postgresql.org; Thu, 18 Jun 2020 23:37:56 +0000 Received: from sonic309-14.consmr.mail.bf2.yahoo.com ([74.6.129.124]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jm46S-0005Hf-9v for pgsql-admin@postgresql.org; Thu, 18 Jun 2020 23:37:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1592523469; bh=G7z5vTwaPMMMwxndeJNmXVu0yXplD5QOMuXUr2Ctb1w=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=aK/QeudH9SMssEO9J+4A5y4PsKjp+YV3y2bTmoqhkMB9hyqrs668lwu2GNFF2Y/ZhvT9l8ePG3nZNgegzYwB50o5W+MD9CXyR3h1TeRvnqFrMTsnaXtJAMU62hR34Iqlr+vKP8bDDssYvLDV2b1IPL6yrSHy6s733iXWoI/i77NXnVUccQu/zWQt/mxSnpUhgnntk/ZwNu/z4YyqMp/qfSItxILUdOGHcQ242Vv5qqWqETwrqZPG8gx7xV3jSBh80nvZiENO0ZrEqOzJ5wP9cF1trMOW1wjuY44bMYnJ994UT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0lBogJUSW6bNP66xYOo3ixudCkWa Ao8aqKFc0Lv4SsZZ7DgmVfECzgxI6_44ZRIVduGTgtu6_WkAvOfkoJG3.7Rcb27z9F_PJURlARbl HUtvaRouQ3YzVsJQUHb5w1iSUok0ltOJLzet1.alMsa1y8FXZ6CiElycdoHZfiaj46Uv.acEQvo_ NcIphQQcNiKG7qFtJIqNYV1OGjqkHKdSCw20DIPdE3msTz3KnFB2TPqH59szTSt2ekT2PpFe3YYA qzbd5CJPD1jkH0hpeuI4ZuFc3j7ri4FJfHzqrytFIk9e1u7UaIHta059vawsjHOfuBiaztR8nLxM GYqLq194Tx4QZ6CWcTL1ODm7GJaWTE7qB2HS08IOfWgBQM_.KFKXa7OHDxVRAGN2MQjTR6s3l58q .ghtz.xIvdGA0YnE1lKPDhoGY2Ll3ig-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.bf2.yahoo.com with HTTP; Thu, 18 Jun 2020 23:37:49 +0000 Date: Thu, 18 Jun 2020 23:37:48 +0000 (UTC) From: Pepe TD Vo Reply-To: Pepe TD Vo To: Christopher Browne , Adrian Klaver Cc: Pgsql-admin , Pgsql-general Message-ID: <11274973.331659.1592523468015@mail.yahoo.com> In-Reply-To: <57eddc72-9278-9e17-3df2-3cd8bb40e82d@aklaver.com> 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> <57eddc72-9278-9e17-3df2-3cd8bb40e82d@aklaver.com> Subject: Re: create batch script to import into postgres tables MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_331658_1460219370.1592523468013" X-Mailer: WebService/1.1.16138 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Content-Length: 12619 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_331658_1460219370.1592523468013 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable thank you for the link.=C2=A0 I did try it and it's still errorecho 'SELECT= count(*) FROM tableA;' | C:\Program Files\PostgreSQL\11\bin\psql -U PSmast= eruser -d PSCIDR -h hostname.amazonaws.com -p 5432 I can run 'psql -u postgres -d PSCIDR -p 5432' (on Linux server, still lear= ning how to run it from psql shell in Window) fine from psql prompt.=C2=A0 = Just still wonder how to connect directly to the instance PSCIDR from scrip= ting in both aws and linux.=C2=A0 Otherwise manually run using pgAdmin. v/r, Bach-Nga No one in this world is pure and perfect.=C2=A0 If you avoid people for the= ir mistakes you will be alone. So judge less, love, and forgive more.To cal= l him a dog hardly seems to do him justice though in as much as he had four= legs, a tail, and barked, I admit he was, to all outward appearances. But = to those who knew him well, he was a perfect gentleman (Hermione Gingold) **Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely = rich *** Faithful talent *** Sharing success =20 On Thursday, June 18, 2020, 07:00:37 PM EDT, Adrian Klaver wrote: =20 =20 On 6/18/20 12:54 PM, Pepe TD Vo wrote: >>>psql -d production=C2=A0 -U postgres -c 'select count(*) from cell_per'; > Null display is "NULL". >=C2=A0 =C2=A0 count > ------- >=C2=A0 =C2=A0 =C2=A0 68 > (1 row) >=20 > you can do this once you are in psql. But if you are running from shell= =20 > script, it will be an error >=20 >=C2=A0 >>What error messages do you get? >=20 > my shell script is: > @echo off > C:\Program Files\PostgreSQL\11\bin\psql -U PSmasteruser=C2=A0 -d PSCIDR -= h=20 > hostname.amazonaws.com -p 5432 -c "select count(*) from tableA;" > pause >=20 > the error I have is 'C:\Program' is not recognized as an internal or=20 > external command, operable program or batch file. >=20 > I even surround the path in quotes because of space. > @echo off > cmd /c ""C:\Program Files\PostgreSQL\11\bin\psql" -U PSmasteruser -d=20 > 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=20 above has unbalanced quotes. >=20 > error is: 'C:\Program Files\PostgreSQL\11\bin\psql: illegal option -- u >=20 > when I put -P Password123 (or fully qualified password=3DPassword123) 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. >=20 > 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. >=20 > I can connect from psql shell fine when it prompt hostname, username=20 > (but connect to postgres not to PSmasteruser, PSmasteruser username set= =20 > up for aws maintenance postgres database, someone did, not me and the=20 > password is same on both).=C2=A0 Once I'm in psql and I can change to PSC= IDR=20 > instance fine and run select count(*) from tableA; >=20 >=20 >=20 > ** > *Bach-Nga >=20 --=20 Adrian Klaver adrian.klaver@aklaver.com =20 ------=_Part_331658_1460219370.1592523468013 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
thank you for the link.  = I did try it and it's still error
echo 'SELEC=
T count(*) FROM tableA;' | 
C:\Program Files\PostgreSQL\11\bin\psql -U = PSmasteruser -d PSCIDR -h hostname.amazonaws.com -p 5432
I can run 'psql -u= postgres -d PSCIDR -p 5432' (on Linux server, still learning how to run it= from psql shell in Window) fine from psql prompt.  Just= still wonder how to connect directly to the instance PSCIDR from scripting= in both aws and linux.  Otherwise manually run using pgAdmin.

v/r,

<= b id=3D"ydpf8dd9bc5yui_3_13_0_rc_1_16_1381789421038_18">Bach-Nga

No one in this world is pure and perfect.&= nbsp; If you avoid people for their mistakes you will be alone. So judge le= ss, love, and forgive more.3D"Emoji"3D"Emoji"3D"Emoji"=
To call him a dog hardly seems to do hi= m justice though in as much as he had four legs, a tail, and barked, I admi= t he was, to all outward appearances. But to those who knew him well, he wa= s a perfect gentleman (Hermione Gingold)

**Live simply **Love generously **Care deepl= y **Speak kindly.
*** Genuinely rich *** Fa= ithful talent *** Sharing success



=20
=20
On Thursday, June 18, 2020, 07:00:37 PM EDT, Adrian Kla= ver <adrian.klaver@aklaver.com> wrote:


On 6/18/20 12:54 PM, Pepe TD Vo wrote= :
>>>psql -d production  -U postgres -c 'se= lect count(*) from cell_per';
> Null display is "NULL"= .
>    count
> -------<= br clear=3D"none">>      68
> (1 row= )
>
> you can do this once you a= re in psql. But if you are running from shell
> scrip= t, 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&nbs= p; -d PSCIDR -h
> hostname.amazonaws.com -p 5432 -c "= select count(*) from tableA;"
> pause
>
> the error I have is 'C:\Program' is not reco= gnized as an internal or
> external command, operable= program or batch file.
>
> I ev= en surround the path in quotes because of space.
> @ec= ho off
> cmd /c ""C:\Program Files\PostgreSQL\11\bin\p= sql" -U PSmasteruser -d
> PSCIDR -h hostname.amazonaw= s.com -p 5432 -c "select count(*) from tableA;"
> paus= e

Not sure how quoting works in Window= s shell scripts, but pretty sure the
above has unbalance= d quotes.


>
> error is: 'C:\Program Files\PostgreSQL\11\bin\psql: ill= egal option -- u
>
> when I put = -P Password123 (or fully qualified password=3DPassword123)

I would recommend spending some time here:

https://www.postgresql.org/doc= s/12/app-psql.html

to see what the= options are. Hint: -P is not the option for password.
>
> it gives me another error "ps= et: unknow option: Password123
> psql: could not set p= rinting parameter "Password123"

It is = the option for pset as the error message says.


>
> I can connect from psql shell fine when it prompt hostname, usern= ame
> (but connect to postgres not to PSmasteruser, P= Smasteruser username set
> up for aws maintenance pos= tgres database, someone did, not me and the
> passwor= d 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
> <= br clear=3D"none">

--
Adrian Klaver
adrian.kla= ver@aklaver.com
------=_Part_331658_1460219370.1592523468013--