Juvenile BASH question
Mark Haney
MHaney at practichem.com
Mon Oct 21 13:30:39 UTC 2013
> su postgres - -c <pgdump command>
>
>
>
> Now, this has worked perfectly for 3 months now, but the last few days
> I started getting errors about failed authentication to the databases. Here's where it gets weird. I can su postgres - from a BASH prompt just fine,but when I run the script, it asks me for a password, which it didn't do before.
> IIRC, I had to change the postgres user from /bin/false to /bin/bash
> for one of our software devs to be able to monitor the DBs via Jenkins, could that have something to do with it? I can't imagine how, since I can su from the root prompt to the postgres user without asking for a password.
>
It's been awhile since I used postgres, having moved to mysql, but if it's asking for the postgres admin password rather than root password, can't you get around it by putting it in a file somewhere like .pgpass or setting an environment variable like PGPASSWORD? Maybe you need to set that in the shell you are created. See:
http://www.postgresql.org/docs/9.1/static/libpq-envars.html
and
http://stackoverflow.com/questions/6523019/postgresql-scripting-psql-execution-with-password
My problem is this, if it works as root from a bash prompt, why /won't/ it work as root from a bash script? Shoudn't it ask for the password in both instances?
More information about the users
mailing list