views:

26

answers:

1

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?

A: 

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

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

should work.

Alex Martelli
agree with your point but could you please tell in short whatz a function of printf at here
sunil
`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.
Alex Martelli