views:

77

answers:

1

I am using batch file to run certain operation in my application. The command I am using does not take password as a parameter instead it prompts for it while running. This is coming in the way of automating this script. I would like to know how I can take password as a parameter and provide to the application when it prompts.

+4  A: 

Reffering to you comment to Johannes' answer, you would need to modify your call to pg_dump to something like this:

echo %3|pg_dump -h %1 -U %2 %4 > %5

The Problem is that pg_dump doesn't allow you to pass in the password via stdin. That means this solution will not work here.

But as you can read in the docs here and here, there is the (unsecure) way of providing the password via environment variable PGPASSWORD.

So simply modify your batch file like this:

...
set PGPASSWORD=%3
pg_dump -h %1 -U %2 %4 > %5
...
Frank Bollack
Thanks this suffices my immediate requirement
Krishna Kumar
+1 and hooray for weird behavior :/
Joey