Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B45647601F for ; Tue, 8 Oct 2002 15:03:39 -0400 (EDT) Received: from secure.pghoster.com (unknown [64.246.32.44]) by postgresql.org (Postfix) with ESMTP id 085A1475F82 for ; Tue, 8 Oct 2002 15:03:39 -0400 (EDT) Received: from pghoster.com (12-239-205-22.client.attbi.com [12.239.205.22]) (authenticated (0 bits)) by secure.pghoster.com (8.11.6/8.11.6) with ESMTP id g98J2w005244; Tue, 8 Oct 2002 14:02:58 -0500 Message-ID: <3DA32C03.9000009@pghoster.com> Date: Tue, 08 Oct 2002 14:03:31 -0500 From: Roj Niyogi User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Elielson Fontanezi Cc: pgsql-general Subject: Re: pg_dump command inside shell scripts References: <200210081504.29059.dev@archonet.com> Content-Type: multipart/alternative; boundary="------------020708050900030106050302" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/470 X-Sequence-Number: 31468 --------------020708050900030106050302 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 > > --------------020708050900030106050302 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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
  
--------------020708050900030106050302--