Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 59F669FB554 for ; Mon, 22 Jan 2007 18:34:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 08728-04 for ; Mon, 22 Jan 2007 18:34:07 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from community1.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id DF86D9FB507 for ; Mon, 22 Jan 2007 18:34:10 -0400 (AST) Received: from [192.168.27.150] (unknown [12.38.10.44]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by community1.commandprompt.com (Postfix) with ESMTP id 3AE3E246DE4; Mon, 22 Jan 2007 14:34:09 -0800 (PST) Message-ID: <45B53BDF.1030909@dunslane.net> Date: Mon, 22 Jan 2007 17:34:07 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.6) Gecko/20060804 Fedora/1.0.4-0.5.1.fc5 SeaMonkey/1.0.4 MIME-Version: 1.0 To: shaunc CC: pgsql-hackers@postgresql.org Subject: Re: send password to pg_dump References: <8473174.post@talk.nabble.com> In-Reply-To: <8473174.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/1006 X-Sequence-Number: 96907 shaunc wrote: > Hello, > > I'm trying to run pg_dump programmatically, and I'm wondering how I can send > it a password. > > I'm running it with a system() call in a child process, and sending the > password in from the parent process on stdin, but somehow pg_dump always > finds out how to ask my terminal for a password. How do I fool it? > > (I need this to work in linux... in python would be preferable too.) > > > 1. this is the wrong forum for this question - here we discuss postgresql developments, not usage 2. use a pgpass file, possibly with a PGPASSFILE environment setting as well - see the docs for details. This works on all platforms and should work with anything at all calling pg_dump. 3. In general, the only way to "fool" programs properly this way is to use expect or some equivalent that uses ptys. In this case, it would be overkill. cheers andrew