[Samba] Using more than one passwd program

Lx lx at survive-linux.com
Fri Jun 24 16:22:16 GMT 2005


Thanks Gemes,

i got it figuered out!!!

here is my script... (for others who seek the same answer)

#!/usr/bin/expect
#
# .htpasswd must be initialized by the beginning of the script
# first run proform a
# htpasswd -c passwordfile user

set timeout 5

# Setting Variables
set user [lindex $argv 0]
set password [lindex $argv 1]
set htpasswdfile "/etc/samba/.htpasswd"
set vhtpasswd "/usr/bin/htpasswd"
set vpasswd "/usr/bin/passwd"


# Start passwd
spawn "$vpasswd" "$user"
expect "*password:*"    {
                        sleep 0.5
                        send "$password\r"
                        }

expect "*password:*"    {
                        sleep 0.5
                        send "$password\r"
                        }

# Only if Passwd is succesful start htpasswd
expect "*passwd:*successfully*" {

        spawn "$vhtpasswd" "$htpasswdfile" "$user"

        expect "*password:"     {
                                sleep 0.5
                                send "$password\r"
                                }

        expect "*password:"     {
                                sleep 0.5
                                send "$password\r"
                                }
}


expect eof


More information about the samba mailing list