thank you for the link. I did try it and it's still error
echo 'SELECT count(*) FROM tableA;' |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.C:\Program Files\PostgreSQL\11\bin\psql -U PSmasteruser -d PSCIDR -h hostname.amazonaws.com -p 5432
v/r,
Bach-Nga
No one in this world is pure and perfect. If you avoid people for their mistakes you will be alone. So judge less, love, and forgive more.
No one in this world is pure and perfect. If you avoid people for their mistakes you will be alone. So judge less, love, and forgive more.
To call 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
On Thursday, June 18, 2020, 07:00:37 PM EDT, Adrian Klaver <adrian.klaver@xxxxxxxxxxx> wrote:
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@xxxxxxxxxxx
>>>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@xxxxxxxxxxx