Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authenticating PostgreSql

Status
Not open for further replies.

BineeshNagoor

Programmer
Mar 17, 2009
3
Hi,
I have one application in that i am using postgreSql as database. I need to authenticate postgreSql while installing the application then only i can dump to the database. I am using installshield for making the setup. Anybody knows how to authenticate using any API or throug batch file Please reply

Thanks in advance..
 
Hi

I understand that you are using Windows and you are the author of an install package.

And the install package contains a dump file and you wish to run it using a command line tool, like [tt]psql[/tt] or [tt]pg_restore[/tt].

But if a database password is set, the above tools will prompt for password. And you wish to avoid that prompt.

If that is your problem, see The Password File in the PostgreSQL documentation. Or you may try to script it with [tt]expect[/tt].

Yep, I know, this is not the answer you expected. Many times I also wish to know a nicer solution...

Feherke.
 
Thank u for ur quick reply..
For dumping to the database i have created one batch file that will call the sql file. the batch file i have written is

set PGPASSWORD=Abc_123
cd\
C:
cd C:\postgres\bin
psql -h localhost -p 5432 -U postgres -f "D:\Application\CreateDatabase.sql"

By running this is it possible to return anything if the password is wrong. that is how to return something from this batch file if the authentication failed..
if know how to do this please reply..
 
Hi

You can do two thing :
[ul]
[li]check the [tt]psql[/tt] command's exit status ( called [tt]errorlevel[/tt] in Windows batch )[/li]
[li]check the [tt]psql[/tt] command's output ( for example [tt]psql | find "ERROR"[/tt] )[/li]
[/ul]
But this is Windows batch question and I can not help more. Try to ask in a Windows forum.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top