Python 如何通过 .py 文件运行 wlst 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20489637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run wlst script by .py file
提问by Thumper
I'm trying to run wlst script form .py file but it can not be done
我正在尝试从 .py 文件中运行 wlst 脚本,但无法完成
Content of .py file :
.py 文件的内容:
connect('weblogic','weblogic','t3://localhost:8001')
sca_undeployComposite('http://localhost:8001','Hello','1.0','user='weblogic',partition='myPartition')
sca_deletePartition('myPartition')
sca_createPartition('myPartition')
sca_deployComposite('http://localhost:8001','C:\WLST\Test\Application.zip',user='weblogic',configplan='myPlan.xml', partition='myPartition')
exit()
when i run cmd file to execute script, Only connect() method is execute success. any command bellow it can not be execute. And error message appear: Problem invoking WLST - Traceback (innermost last): File "c:\WLS\script\filname.py", line 2, in ? Name Error: sca_undeployComposite
当我运行 cmd 文件来执行脚本时,只有 connect() 方法执行成功。它下面的任何命令都无法执行。并且出现错误消息:Problem invoking WLST - Traceback(最后一层):File "c:\WLS\script\filname.py", line 2, in ? 名称错误:sca_undeployComposite
Please help me to resolve it. Thanks !
请帮我解决它。谢谢 !
采纳答案by PavanDevarakonda
The commands after the connect() line which are not regular WLST commands. They requires sca related libraries into CLASSPATH. if you look into your wlst.cmd or .sh file that is actually calling the environment setup file that could be setWLSEnv.sh/.cmd. If you run that from where you are having the this python script. That script will work, it is simple java CLASSPATH funda nothing else!
connect() 行之后的命令不是常规的 WLST 命令。他们需要将 sca 相关库放入 CLASSPATH。如果您查看实际调用环境设置文件的 wlst.cmd 或 .sh 文件,该文件可能是 setWLSEv.sh/.cmd。如果你从你有这个 python 脚本的地方运行它。那个脚本可以工作,很简单 java CLASSPATH funda 没有别的!
Probably you might be running wlst.cmd after navigating to the common bin folder like
导航到常见的 bin 文件夹后,您可能正在运行 wlst.cmd,例如
cd /oracle/fmwhome/Oracle_SOA1/common/bin/.
instead you can run in your script like this
相反,您可以像这样在脚本中运行
C:\WLS\script\>/oracle/fmwhome/Oracle_SOA1/common/bin/wlst.cmd filename.py
or
或者
C:\WLS\script\>/oracle/fmwhome/Oracle_SOA1/common/bin/setWLSEnv.cmd
C:\WLS\script\>java weblogic.WLST filename.py
You can also refer for more sca related scripting: WLSTByExamples
您还可以参考更多与 sca 相关的脚本:WLSTByExamples

