Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piping password to smbpasswd

How can I pipe the new password to smbpasswd so I can automate my installation process.

like image 967
UnkwnTech Avatar asked Aug 15 '08 06:08

UnkwnTech


3 Answers

Thanks to Mark I found the answer:

(echo newpassword; echo confirmNewPassword) | smbpasswd -s

BTW: (echo oldpasswd; echo newpasswd) | smbpasswd -s does not work.

like image 141
UnkwnTech Avatar answered Oct 16 '22 07:10

UnkwnTech


I use the following in one of my scripts:

   echo -ne "$PASS\n$PASS\n" | smbpasswd -a -s $LOGIN

With echo:

-e : escape sequences, like \n

-n : don't add implicit newline at end

With smbpasswd:

-a : add new user

-s : silent

like image 27
Bruno De Fraine Avatar answered Oct 16 '22 08:10

Bruno De Fraine


Try something like this:

(echo oldpasswd; echo newpasswd) | smbpasswd -s
like image 13
Mark Harrison Avatar answered Oct 16 '22 09:10

Mark Harrison