Batch authentication with psql -- SOLVED - Mailing list pgsql-admin

From David F. Skoll
Subject Batch authentication with psql -- SOLVED
Date
Msg-id Pine.LNX.4.44.0207291117130.2557-100000@shishi.roaringpenguin.com
Whole thread Raw
List pgsql-admin
Hi,

I needed a way to supply a password to psql from shell scripts and
cron jobs, but didn't want to install "expect" -- too complex.

I wrote a simple little C program called "notty" which convinces psql
that it has no controlliny TTY, and then it reads the password from
stdin.

So instead of:

    psql [options] < commands.sql

You use:

    (echo "password"; cat commands.sql) | notty psql [options]

The C source code is at http://www.roaringpenguin.com/notty.c.txt

It is verified to work on Linux and Solaris, and should work on any
modern UNIX.  On any decent UNIX system, you should be able to save
the file as "notty.c" and type:

    make notty

to build it.

Regards,

David.


pgsql-admin by date:

Previous
From: Jodi Kanter
Date:
Subject: Re: bitwise AND
Next
From: "Jan Hartmann"
Date:
Subject: Re: Multiple Postmasters on Beowulf cluster