Hello Samba Team, I am writing a script that add Linux user with useradd command and then I would like to add samba user using smbpasswd command but when my script run the smbpasswd it ask me password two times but in my script I already ask your to enter password. So I have user password into variable so now need to tweak smbpasswd that way that is going to take my variable password instead of asking me. Thanks in advance. -- Thank You, Jigar.
From: Jigar Patel <pateljigar.83 at gmail.com> Date: Tue, 7 Jun 2011 16:36:28 -0700 (snip)> So I have user password into variable so now need to > tweak smbpasswd that way that is going to take my variable password instead > of asking me. Thanks in advance.You can do this like that: # (echo password; echo password) | smbpasswd -s monyo Password changed for user monyo --- TAKAHASHI Motonobu <monyo at monyo.com> / @damemonyo http://damedame.monyo.com/ / http://facebook.com/monyot
Also You can use "expect" command to do this. This is a sample program I used to change unix user passwords. You can edit it to do this job. #!/bin/sh # \ exec expect -f "$0" ${1+"$@"} set password [lindex $argv 1] spawn passwd [lindex $argv 0] sleep 1 expect "assword:" send "$password\r" expect "assword:" send "$password\r" expect eof On 06/12/2011 08:53 PM, TAKAHASHI Motonobu wrote:> From: Jigar Patel<pateljigar.83 at gmail.com> > Date: Tue, 7 Jun 2011 16:36:28 -0700 > > (snip) >> So I have user password into variable so now need to >> tweak smbpasswd that way that is going to take my variable password instead >> of asking me. Thanks in advance. > You can do this like that: > > # (echo password; echo password) | smbpasswd -s monyo > Password changed for user monyo > > --- > TAKAHASHI Motonobu<monyo at monyo.com> / @damemonyo > http://damedame.monyo.com/ / http://facebook.com/monyot >