×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Authenticating PostgreSql

Authenticating PostgreSql

Authenticating PostgreSql

(OP)
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..

RE: Authenticating PostgreSql

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 psql or pg_restore.

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 expect.

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

Feherke.
http://rootshell.be/~feherke/

RE: Authenticating PostgreSql

(OP)
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..

RE: Authenticating PostgreSql

Hi

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

Feherke.
http://rootshell.be/~feherke/

RE: Authenticating PostgreSql

(OP)
Thank u for your nice advice..

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close