R
R
Reshh4rd2018-09-05 16:09:42
linux
Reshh4rd, 2018-09-05 16:09:42

How to put passwd password input in script?

In the python2.4 script, you need to set a password for the user usertest, let's say 123:
passwd = "123"
os.system(passwd usertest)
What the OS returns:
Changing password for usertest.
New password:
How to automatically substitute the password from the variable after the password prompt. (It is possible not from a variable, the main thing is that this process can be automated)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-09-05
@Reshh4rd

Pass password with passwd
parameters it not to a python questions, namely to passwd.
You can use other tools if they are in the system, for example:
usermod --password PASSWORD USERNAME

R
Ruslan Fedoseev, 2018-09-05
@martin74ua

the passwd command is special. And to accept the password as argument - does not want. Read the documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question