Need Control from Unix shell -> Python -> & back

做~自己de王妃 提交于 2019-12-11 05:44:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!