chpasswd outputs informational messages to stderr
I'm trying to make command chpasswd
silent on success. In a system where user 'git' exists but user 'bob' doesn't the following output is given by chpasswd
:
/ # echo git:1234 | chpasswd 1>stdout.txt 2>stderr.txt
/ # cat stdout.txt
/ # cat stderr.txt
chpasswd: password for 'git' changed
/ # echo bob:1234 | chpasswd 1>stdout.txt 2>stderr.txt
/ # cat stdout.txt
/ # cat stderr.txt
chpasswd: unknown user bob
I would expect the first command to produce its output on stdout instead of stderr since it successfully changed the password for the given user and no error ocurred. The second case (when the user does not exist) behaves exactly as expected.