multiple command execution

2019-05-23 16:53发布

I have created a installer with innosetup and i wanna use it to create a postgresql database using psql.exe . I call the psql.exe with this line of code :

Filename: "{app}\PostgreSQL\bin\psql.exe"; Parameters: "-W postgres";

The problem is that psql ask for user password and there is no option to pass it in one call .

Is it possible to simulate the "Enter" key and add the password just after ? If there is another solution let me know please.

Thanks .

1条回答
欢心
2楼-- · 2019-05-23 17:19

There is the PGPASSWORD environment variable:

PGPASSWORD behaves the same as the password connection parameter. Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps; instead consider using the ~/.pgpass file.

As mentioned, there is also the password file but the environment variable would probably be fine for an installer. In either case you'd drop the -W switch.

You could also build a special purpose tool to talk to PostgreSQL directly rather than go through psql.exe.

查看更多
登录 后发表回答