多命令执行 [英] multiple command execution
问题描述
我用innosetup创建了一个安装程序,我想用它使用psql.exe创建一个postgresql数据库。
我用以下代码行调用psql.exe:
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 :
文件名: {app} \PostgreSQL\bin\psql.exe;参数: -W postgres;
Filename: "{app}\PostgreSQL\bin\psql.exe"; Parameters: "-W postgres";
问题是psql要求输入用户密码,没有选择在一次调用中传递该密码。
The problem is that psql ask for user password and there is no option to pass it in one call .
是否可以模拟 Enter键并在之后添加密码?
如果还有其他解决方案,请告诉我。
Is it possible to simulate the "Enter" key and add the password just after ? If there is another solution let me know please.
谢谢。
推荐答案
PGPASSWORD
的行为与密码连接参数相同。出于安全原因,不建议使用此环境变量,因为某些操作系统允许非root用户通过ps查看进程环境变量。而是考虑使用〜/ .pgpass
文件。
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.
如上所述也是密码文件,但环境变量可能没问题对于安装程序。无论哪种情况,您都可以放下 -W
开关。
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.
您还可以构建一个专用的工具来进行通话直接到PostgreSQL,而不是通过 psql.exe
。
You could also build a special purpose tool to talk to PostgreSQL directly rather than go through psql.exe
.
这篇关于多命令执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!