Re: Postgresql and shell script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Tronn Wærdahl wrote:
I have a shell script (sh) where I create a user and import data to a postgres database

<snip>
su -c "createuser -A -D -P $PG_user" postgres
su -c "psql -d$PG_database -h localhost -U$PG_user -W -f postgresql.sql " postgres
</snip>


I think, the usage of sudo would solve your problem.

Regards

Joachim Backes

when the script executes those command, it ask for a password, how could I do this without have to enter the passwd, I would like that it reads the password from a variabel, that excists in a separate file, like

<variable file>
PG_passwd=secret
PG_user =username
PG_database=simple
</variable file>


Tronn


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

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


--
Joachim Backes <joachim.backes@xxxxxxxxxxxxxx>
University of Kaiserslautern,Computer Center [RHRK],
Systems and Operations, High Performance Computing,
D-67653 Kaiserslautern, PO Box 3049, Germany
--------------------------------------------------
Phone: +49-631-205-2438, FAX: +49-631-205-3056
http://hlrwm.rhrk.uni-kl.de/home/staff/backes.html

<<attachment: smime.p7s>>

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux