Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters to psql.exe

I want to launch psql.exe from an application. The user locates the script, so it could be anywhere on his disk, and the application just feeds that script to psql. That's about it.

What's the correct command line for that ?

I tried this with no success

"C:\Program Files\PostgreSQL\9.1\bin\psql.exe" TEST SYSADM -f "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.sql"

I tried with quotes, without the quotes, none worked, it's just ignoring the arguments (tried this on cmd.exe)

C:\Documents and Settings\Administrateur>"C:\Program Files\PostgreSQL\9.1\bin\psql.exe" TEST SYSADM -f "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.
sql"
psql: warning: extra command-line argument "-f" ignored
psql: warning: extra command-line argument "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.sql" ignored
Password for user SYSADM:

Yes, if the script is in the same directory as psql.exe, and if I CD first to where psql.exe is installed, that means no quotes, no absolute paths and it works fine. However, in my case, I want the application to work on any windows installation, that means psql.exe could be anywhere and the sql script also could be anywhere. I still want the script to be fed to psql.exe.

like image 834
ychaouche Avatar asked May 22 '12 17:05

ychaouche


1 Answers

Try this:

"C:\Program Files\PostgreSQL\9.1\bin\psql.exe" -f "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.sql" TEST SYSADM 
like image 85
Quassnoi Avatar answered Oct 01 '22 13:10

Quassnoi