问题
There is a weblogic script test.sh which has the below code.
echo "Starting ...."
java weblogic.WLST helloworld.py
echo "Ending ..."The output after printing "Starting ...."
The second line of code prompts for the below msg
Creating the key file can reduce the security of your system if it is not kept in a secured location after it is created. Do you want to create the key file? y or n
Then I have to manually press y or n which I wish to automate as 'y'.
This I am excepting with no user intervention be required.
I need to somehow automatically pass 'y' so that the script continues flow and not stop for user input.
Below are the contents of the helloworld.py script
connect(user1,p@ss,'t3://myhost:9999')
storeUserConfig(userConfigFile='userconfig.secure',userKeyFile='userkey.secure')
disconnect()
exit()
Can you help me please ?
回答1:
You can execute the java weblogic.WLST helloworld.py
command as a subprocess in python. Then you can parse the output for the mentioned question and enter the 'y' via stdin.write('y\n')
.
来源:https://stackoverflow.com/questions/15268745/need-control-from-unix-shell-python-back