Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id AD4C41337999 for ; Tue, 26 Oct 2010 05:51:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 40757-06 for ; Tue, 26 Oct 2010 08:51:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 631A5133616B for ; Tue, 26 Oct 2010 05:51:09 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PAfFK-0007Z8-Lk for pgsql-admin@postgresql.org; Tue, 26 Oct 2010 10:51:06 +0200 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Oct 2010 10:51:06 +0200 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Oct 2010 10:51:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Thomas Kellerer Subject: Re: Creating role using batch file in windows Date: Tue, 26 Oct 2010 10:50:58 +0200 Lines: 48 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.746 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_NUMERIC_HELO=1.164, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/184 X-Sequence-Number: 35925 Lukasz Brodziak, 26.10.2010 08:58: >> The problem with a batch file is that you will need to provide the password >> for the superuser in clear text - which is probably not something you will >> want to do. >> >> But if that isn't a problem (and you actually know the superuser password of >> your client) then the following might work: >> >> ------------- snip --------------- >> @echo off >> setlocal >> >> set PGHOST=localhost >> set PGUSER=postgres >> set PGPASSWORD=the_super_secret_password >> >> createuser role_1 1> nul 2>&1 >> createuser role_2 1> nul 2>&1 >> ... >> >> endlocal >> ------------- snip --------------- >> >> > One more question. Does the SET PGPASSWORD sets pass for the role? No, it sets the password for the superuser (the one that is needed to run createrole) > If not how to set the password for the role using the script provided. I don't think this can be specified with createuser, but you could use psql to run a single statememt. Something like: psql -c "create role new_role with password 'new_roles_password'" (You might need to play around with the quoting) The environment variables are then used to establish the connection to the correct Postgres instance. Regards Thomas