需要来自 Unix shell 的控制 ->蟒蛇->&背部 [英] Need Control from Unix shell -> Python -> & back

查看:29
本文介绍了需要来自 Unix shell 的控制 ->蟒蛇->&背部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个具有以下代码的 weblogic 脚本 test.sh.

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 ...." 

第二行代码提示下面的msg

The second line of code prompts for the below msg

创建密钥文件会降低系统的安全性,如果它是创建后未保存在安全位置.你想要_____吗创建密钥文件?y 或 n

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

然后我必须手动按 y 或 n,我希望自动按 'y'.

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.

我需要以某种方式自动传递 'y' 以便脚本继续运行而不停止用户输入.

I need to somehow automatically pass 'y' so that the script continues flow and not stop for user input.

以下是helloworld.py脚本的内容

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()

你能帮我吗?

推荐答案

您可以将 java weblogic.WLST helloworld.py 命令作为 Python 中的子进程执行.然后,您可以解析上述问题的输出,并通过 stdin.write('y\n') 输入y".

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').

这篇关于需要来自 Unix shell 的控制 ->蟒蛇->&背部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆