Hi Thomas,
today, I played around with WbSysExec to import a dump using psql.
It would work, but for psql you need to set the system environment variable PGPASSWORD (see
https://www.postgresql.org/docs/9.5/static/libpq-envars.html) in order to provide the password. The default password file didn't work on my Win machine; furthermore the usage of these imports should be as easy and hassle free, so it would be nice to pass the password by just setting PGPASSWORD.
When typing on cmd everything works:
set PGPASSWORD=my_pwd
psql.exe -d sapient -U postgres -f C:/projects/backup.sql -L C:/projects/psql.log -w
I tried following (using a simple command to verify it works when it has been logged the version):
-- TRY 1
WbSysExec -program='cmd.exe' -argument='/c' -argument='set PGPASSWORD=my_pwd/n';
WbSysExec -dir=ZZZPATH2PSQLZZZ
-program=psql.exe
-argument='-d sapient -U postgres -c "select version()" -L C:/projects/JLIW/db_dev_636/psql.log -w';
-- TRY 2
WbSysExec -dir=ZZZPATH2PSQLZZZ
-program='cmd.exe'
-argument='/c'
-argument='set PGPASSWORD=my_pwd\n psql.exe -d sapient -U postgres -c "select version()" -L C:/projects/JLIW/db_dev_636/psql.log -w';
It would be nice to pass system variables to WbSysExec, for example:
WbSysExec -sysvar=PGPASSWORD=my_pwd
I tried this in class WbSysExec, but just setting the system variable by System.setProperty does not work.
Have you any idea? Would it be possible to realize this feature?
Thanks in advance,
Franz