From: Roj Niyogi <niyogi@pghoster.com>
To: Elielson Fontanezi <ElielsonF@prodam.sp.gov.br>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: pg_dump command inside shell scripts
Date: Tue, 08 Oct 2002 14:03:31 -0500
Message-ID: <3DA32C03.9000009@pghoster.com> (raw)
References: <A799F7647794D311924A005004ACEA9708A246A4@cprodamibs249.prodam>
<200210081504.29059.dev@archonet.com>
Hi,
Yes, Richard is right about suggesting the expect command. If you're
running a Red Hat-based system, you can download the expect rpm from
rpmfind.net.
Once you've installed this, create a file called pg-script.exp and put
the following in there:
#!/usr/bin/expect -f
set username [lindex $argv 0]
set password [lindex $argv 1]
set database [lindex $argv 2]
spawn {pg_dump} -u -Ft $database --file=$database.sql.tar
expect "Username:"
send "$username\r"
expect "Password:"
send "$password\r"
expect eof
This will take the username as the 1st argument, password as the second
argument and database as the third. Dumps them into local variables and
passes the values when prompted by postgresql. It "expects" Username:
and when comes across that, it sends the value for username along with a
carriage return.
Note that it assumes that expect binary is in the /usr/bin directory.
:)
Roj Niyogi
niyogi@pghoster.com
pgHoster - PostgreSQL Web Hosting
http://www.pghoster.com
Richard Huxton wrote:
>On Tuesday 08 Oct 2002 2:35 pm, Elielson Fontanezi wrote:
>
>
>>Hi Folks!
>>
>> Again I need a help from you!
>>
>> I have develop a shell script (seen below) to do dump and vaccum
>>automatically.
>>
>>
>
>
>
>> But now I need change the $PGDATA/*hba.conf file as it was originally
>>and
>>face the password prompt again.
>>
>>
>
>Do a search on "expect" - probably included with your system and designed for
>this sort of interactive chatting (traditionally with a modem). There's also
>a perl module to do the same.
>
>- Richard Huxton
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo@postgresql.org so that your
>message can get through to the mailing list cleanly
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: niyogi@pghoster.com, ElielsonF@prodam.sp.gov.br, pgsql-general@postgresql.org
Subject: Re: pg_dump command inside shell scripts
In-Reply-To: <3DA32C03.9000009@pghoster.com>
References: <A799F7647794D311924A005004ACEA9708A246A4@cprodamibs249.prodam> <200210081504.29059.dev@archonet.com> <3DA32C03.9000009@pghoster.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox