pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedCreating role using batch file in windows
4+ messages / 2 participants
[nested] [flat]
* Creating role using batch file in windows
@ 2010-10-25 13:49 Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-25 14:05 ` Re: Creating role using batch file in windows Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Brodziak @ 2010-10-25 13:49 UTC (permalink / raw)
To: pgsql-admin
Hello,
What I need to do is create a batch file to be sent to client in which
I have to perform create role statement. Best thing would be if the
user didn't see what is happening in the console (is there a @echo off
equivalent for psql). Can anyone help me with this.
--
Łukasz Brodziak
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating role using batch file in windows
2010-10-25 13:49 Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
@ 2010-10-25 14:05 ` Thomas Kellerer <spam_eater@gmx.net>
2010-10-26 06:58 ` Re: Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Kellerer @ 2010-10-25 14:05 UTC (permalink / raw)
To: pgsql-admin
Lukasz Brodziak, 25.10.2010 15:49:
> Hello,
>
> What I need to do is create a batch file to be sent to client in which
> I have to perform create role statement. Best thing would be if the
> user didn't see what is happening in the console (is there a @echo off
> equivalent for psql). Can anyone help me with this.
>
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 ---------------
Regards
Thomas
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating role using batch file in windows
2010-10-25 13:49 Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-25 14:05 ` Re: Creating role using batch file in windows Thomas Kellerer <spam_eater@gmx.net>
@ 2010-10-26 06:58 ` Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-26 08:50 ` Re: Creating role using batch file in windows Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Brodziak @ 2010-10-26 06:58 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-admin
One more question. Does the SET PGPASSWORD sets pass for the role? If
not how to set the password for the role using the script provided.
2010/10/25 Thomas Kellerer <spam_eater@gmx.net>:
> Lukasz Brodziak, 25.10.2010 15:49:
>>
>> Hello,
>>
>> What I need to do is create a batch file to be sent to client in which
>> I have to perform create role statement. Best thing would be if the
>> user didn't see what is happening in the console (is there a @echo off
>> equivalent for psql). Can anyone help me with this.
>>
>
> 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 ---------------
>
>
> Regards
> Thomas
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>
--
Łukasz Brodziak
II MU Bioinformatyka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating role using batch file in windows
2010-10-25 13:49 Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-25 14:05 ` Re: Creating role using batch file in windows Thomas Kellerer <spam_eater@gmx.net>
2010-10-26 06:58 ` Re: Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
@ 2010-10-26 08:50 ` Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Kellerer @ 2010-10-26 08:50 UTC (permalink / raw)
To: pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2010-10-26 08:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 13:49 Creating role using batch file in windows Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-25 14:05 ` Thomas Kellerer <spam_eater@gmx.net>
2010-10-26 06:58 ` Lukasz Brodziak <lukasz.brodziak@gmail.com>
2010-10-26 08:50 ` Thomas Kellerer <spam_eater@gmx.net>
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