12

I want to make creating a samba password automated but this command doesn't work:

echo "passwd"|smbpasswd -a -s $user

It shows this error:

Mismatch - password unchanged. Unable to get new password.

Could you please suggest any option to make my script automated?

2 Answers 2

21

You need to repeat the password, "for confirmation" so to speak, so e.g.

printf "passwd\npasswd\n" | smbpasswd -a -s $user

should work.

2
  • 1
    agree with your point but could you please tell in short whatz a function of printf at here
    – sunil
    Jul 24, 2010 at 5:49
  • 1
    printf is a shell command specified in IEEE Std 1003.2-1992 (``POSIX.2'') that's more powerful than echo because it easily lets you specify formatting options -- man 1 printf (not to be confused with man 3 printf which documents the similar function in the C standard library) will give you all the details. Jul 24, 2010 at 6:13
1

The printf solution above works perfect, but also echo -e works fine

echo -e "yourpass\nyourpass\n" |smbpasswd -a -s youruser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.