When i execute the below command, it usually asks for the user input. How can we automate the user interaction in python script.
os.system("openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095")
For that specific command, you should not need any automation tool to feed input to your script. Piping a file to it should allow it to execute without user interaction (like Coldspeed said in his comment).
Most command line interfaces allow parametrized execution and most parameters you can either build into your script or read them from a config file somewhere.
For those command line tools that require "real" user interaction (i.e. you can't pipe the input, parametrize it or somehow build it into the command itself), I used the pexpect module with great success.
How can we automate the user interaction in python script