I've wrote function in node,js as follows:
const addUserToSamba = (userLogin, password) => {
const echoPassword = spawnSync('echo', ['ne',`${password}\n${password}\n`]);
const addUserCredentialsToSamba = spawnSync('smbpasswd', ['-a', '-s', userLogin], {
input: echoPassword.stdout,
});
console.log('Added user credentials to Samba configuration');
console.log(addUserCredentialsToSamba.stderr.toString());
console.log(addUserCredentialsToSamba.stdout.toString());
}
I want to achieve something like this in bash:
echo -ne "$PASS\n$PASS\n" | smbpasswd -a -s $LOGIN
When I'm running addUserToSamba(userLogin, password); function with given userlLogin and user password then I even get message Added user ${userLogin} as a stdout of the addUserCredentialsToSamba outcome.
But the credentials don't work.
Have I correctly rewritten this bash function to the node.js one? If no, how can I fix it?