Reputation: 5901
If I run adduser testuser
from the terminal the command asks me some questions like for a password. But this code:
import os
a = os.system('useradd testuser')
exist with error code 0 (no problem there). But it don't asks any question. Why is that? And how can I work around it. I also tried subprocess which did the same thing.
Upvotes: 0
Views: 198
Reputation: 408
Do you mean it didn't finish, or did you not see the expected results.
Also, did you notice that you said "adduser" in the text of your question but "useradd" in the python code? You may have confused these two similar commands!
Upvotes: 2
Reputation: 601559
This is because adduser
and useradd
are two different programs. The former asks interactive questions, the latter doesn't. If you want the interactive prompts, call adduser
, and use subprocess.call()
to do so.
Upvotes: 8