encrypt() problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Murrell

    #1

    encrypt() problem

    Hello,

    I am setting up a Postfix + MySQL + Courier-IMAP system. I am trying
    to write a shell script which will insert the values into the
    database. For the password encryption, I wish to use MySQL's
    encrypt() function. Thisis what I have in my script:

    echo "INSERT INTO users(id,addres s,crypt,clear,n ame,domain,mail dir)" >
    /tmp/insert.sql
    echo " VALUES('$name@$ domain','$name@ $domain','encry pt('$password') ','$password',' $name','$domain ','$userDir/Maildir')"[color=blue][color=green]
    >> /tmp/insert.sql[/color][/color]
    mysql -h $dbhost -u $dbuser -p$dbpass $dbname < /tmp/insert.sql

    Assuming that the value of $password is "password", instead of the
    encrypted version of "password", I get the following in the "crypt"
    field:

    encrypt('passwo rd')

    I believe this has something to do with the use of the single quotes
    around 'encrypt('$pass word')', but I do not know how to work around
    that.

    Does anyone have any ideas on how to do this?

    TIA for your help.

    Alan Murrell <swasak@hotmail .com>
Working...