Hello Everybody, i try to use more than the common: passwd program = /usr/bin/passwd %u what i try to do is a passwd program = /usr/bin/passwd %u && /usr/bin/htpasswd /location/of/file %u it works perfect with /usr/bin/passwd... but i just can?t get it to make an entry to /usr/bin/htpasswd can someone please help me best regards Alex
lx wrote:> Hello Everybody, > > i try to use more than the common: > > passwd program = /usr/bin/passwd %u > > what i try to do is a > > passwd program = /usr/bin/passwd %u && /usr/bin/htpasswd > /location/of/file %u > > it works perfect with /usr/bin/passwd... > > but i just can?t get it to make an entry to /usr/bin/htpasswd > > can someone please help me > > best regards > AlexIn that case you might want to write an expect script which would invoke /usr/bin/passwd and /usr/bin/htpaswd, and tell your samba, that your password program is that script. Good Luck! Geza
lx ?rta:> G?mes G?za schrieb: > >> lx wrote: >> >>> Hello Everybody, >>> >>> i try to use more than the common: >>> >>> passwd program = /usr/bin/passwd %u >>> >>> what i try to do is a >>> >>> passwd program = /usr/bin/passwd %u && /usr/bin/htpasswd >>> /location/of/file %u >>> >>> it works perfect with /usr/bin/passwd... >>> >>> but i just can?t get it to make an entry to /usr/bin/htpasswd >>> >>> can someone please help me >>> >>> best regards >>> Alex >> >> >> >> In that case you might want to write an expect script which would >> invoke /usr/bin/passwd and /usr/bin/htpaswd, and tell your samba, >> that your password program is that script. >> >> Good Luck! >> >> Geza > > > Hi Geza, > > thanks for the reply, how could such a script look like? > > i still dont understand the linux way of transfering variables... > > could you give me a hint? > > i got some thin like this > > <> > > #!/bin/sh > > /usr/bin/passwd $1 > /usr/bin/htpasswd /location/of/file $1 > > <> > > is this right? > > Best regards, > > L > xYou could try something like that: #!/usr/bin/expect spawn /usr/bin/passwd [lindex $argv 0] set password [lindex $argv 1] expect "New UNIX password:" send "$password\r" expect "Retype new UNIX password:" send "$password\r" expect "passwd: all authentication tokens updated successfully." send "\r" spawn /usr/sbin/htpasswd -c passwdfile [lindex $argv 0] expect "password:" send "$password\r" expect "password:" send "$password\r" expect eof Please try it on the command line first, as I'm not an expect expert ;-( Cheers Geza
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