开发者

How to use a command line parameter to supply input in subsequent prompt (batch file)

I am using batch file to run certain operation in my application. The command I am using do开发者_开发问答es 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.


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
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜