Re: Authentication in batch processing - Mailing list pgsql-admin

From Bruce Momjian
Subject Re: Authentication in batch processing
Date
Msg-id 200206022022.g52KM8m18308@candle.pha.pa.us
Whole thread Raw
In response to Authentication in batch processing  (Hal Lynch <hal@cc.usu.edu>)
List pgsql-admin
Password prompting was changed in 7.2.X.  You can now pass a script into
psql, and you will be prompted for the password on your terminal rather
than having the password coming from the script.

The best way send the password in 7.2.X is to use 'expect', or use the
PGPASSWORD environment variable. (However, on some OS's, environment
values like PGPASSWORD can be seen by 'ps'.)  Another option is that if
/dev/tty can't get opened, the password will be requested from stdin.
Unfortunately, I can't think of an easy way to make /dev/tty fail.

---------------------------------------------------------------------------

Hal Lynch wrote:
> I have postgres set up to require usernames and passwords for access.
>
> The following script works just fine in 7.1.2 without manual
> intervention.  Using 7.2.1 psql issues a password prompt and
> blocks until a password is manually entered.
>
> #######################################
> #!/bin/sh
>
> psql mydb <<\__EOD__
> mypassword
> create table mytable
>     (
>     ssn        char(9),
>     name    char(50)
>     );
> __EOD__
> #######################################
>
> For several years now I have been using scripts like the above
> to drop and create 14 databases, and create and populate ~100
> tables on a nightly basis.  I need this or something like it
> to work.
>
> As always I assume I am doing dumb.
>
> Can someone help?
>
> hal
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-admin by date:

Previous
From: "Raymond Chui"
Date:
Subject: How to partial dump the log in SQL?
Next
From: Bruce Momjian
Date:
Subject: Re: configure datatype name > 31?