#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13

    Password prompt in script ??


    I have the following statement...

    Code:
    psql test -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
    which was working perfectly well using 'trust' authentication.

    However, now I have changed the database setting to 'md5' for encrypted password authentication.

    Now, the above code fails with...


    Password:
    psql: fe_sendauth: no password supplied
    I tried passing the password in the above code using -U & -W but it does not work. Is any other option is available ?

    Do give your valuable input.

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    409
    Rep Power
    13
    I think for using md5, you will have to setup postgres password and/or shadow files. Note that these are not the UNIX password and shadow files, but are a postgres specific version of thems separate from UNIX. Section 4.2.2 explains it in more detail:

    http://www.postgresql.org/idocs/inde...h-methods.html

    Did you also setup the user with encrypted password?


    CREATE USER test WITH ENCRYPTED PASSWORD 'blah';

    This user also referred to setting up md5 in the pg_hba.conf file:

    http://dbforums.com/t322752.html
    Last edited by Ted Striker; October 15th, 2002 at 07:51 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13
    Thanks for your reply. The info was very useful.

    However, I'm sorry to have not been clear in my posting...

    I'm able to connect using a password, ...


    postgres@sun051 pgsql]$ psql run
    Password:
    Welcome to psql, the PostgreSQL interactive terminal.

    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help on internal slash commands
    \g or terminate with semicolon to execute query
    \q to quit

    run=#
    however when I want to connect using a script to take backup, it fails with the error mentioned as there is no password supplied.

    So, for this, I wonder if there is an option to pass a password in the script.

    Best Regards.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    409
    Rep Power
    13
    What error messages do you get when you use the -U & -W ?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13
    Originally posted by Ted Striker
    What error messages do you get when you use the -U & -W ?
    It still asks for password ...


    [postgres@sun051 pgsql]$ cat bk3.sh
    psql dev -U postgres -W postgres -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
    psql dev -U postgres -W postgres -t -c "select 'pg_dump dev > dev'||name||'.dmp' from d_conf_backup" > bk4.sh
    chmod 755 bk4.sh
    [postgres@sun051 pgsql]$ ./bk3.sh
    psql: warning: extra option postgres ignored
    Password:
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    409
    Rep Power
    13
    Looks like this is beyond me. Perhaps there is some kind of certificate or password file that needs to be set up.

    Your best bet here would be to get on one of the Postgres mailing lists. Sometimes Tom Lane or Bruce Momjain will respond personally.
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Posts
    56
    Rep Power
    13
    You can pass a password in a script, it just isn't easy on 7.2 - I believe 7.3 will have a better fix for this by allowing you to specify a password file.

    You can try env. vars PGUSER PGPASSWORD, although some os's will display that in ps - not a good idea for security.

    Here's another method that will let the password be accepted from stdin.

    http://groups.google.com/groups?q=po...uin.com&rnum=3
    Casuistry Agnostic
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13
    Originally posted by ultraslacker

    Here's another method that will let the password be accepted from stdin.

    http://groups.google.com/groups?q=po...uin.com&rnum=3
    Thanks a mil ! This worked out.

    Regards.

IMN logo majestic logo threadwatch logo seochat tools logo