【问题标题】:How to pass a parameter from Shell to WLST script如何将参数从 Shell 传递到 WLST 脚本
【发布时间】:2020-12-31 10:23:20
【问题描述】:

编辑:问题已解决。但我把它留在这里,这样其他人就会从这里受益。如果不行,我会删除问题。

我想按顺序自动停止服务器。因此,我已经用 python 和 bash 编写了一个脚本。 WLST 脚本

import sys
managedserver = sys.argv[1]
#while True:
#   try:
#   connect('weblogic', 'weblogic1', 't3://machine-1:7001')
#   break
#   
#   except Exception:
#   print("can't connect to AdminServer")
connect('weblogic', 'welcome1', 't3://machine-1:7001')

shutdown(managedserver,ignoreSessions='false', force='false')
#if state(managedserver,name='managedserver') == 'SUSPENDED':
#   time.sleep(60)
#   shutdown(managedserver,name='managedserver',ignoreSessions='true', force='true')
#elif state(managedserver,name='managedserver') == 'RUNNING':
#   shutdown('managedserver',name='managedserver',ignoreSessions='true', force='true')
#else:
#   break

exit()

我使用以下脚本调用该脚本。

echo "############################"
echo "# All Servers are STOPPING #"
echo "############################"
# Shutting down servers
WLST_Bin=/data/mw/12213/wls/ohome/oracle_common/common/bin
for managedserver in MOBIL-TEST-S01-2201 MOBIL-TEST-S01-2202
do 
    echo " Shutting Down ${server} !!! "
    sh ${WLST_Bin}/wlst.sh ServerStop.py $managedserver
    sleep 600
    
done

我得到的错误是WLSTException: Error occurred while performing shutdown : No server, cluster, system component or system component configuration with name "managedserver" configured in the domain

这是由于我无法将参数传递给 WLST 脚本。我在网上搜索,但没有找到任何东西。

【问题讨论】:

  • 这可能会有所帮助:How to debug a bash script?
  • 是的,我知道,正如我所说,它位于尝试连接的线路上。感谢您提供有用的信息

标签: bash weblogic wlst


【解决方案1】:

您可以将参数传递给 WLST 脚本。你应该使用sys.argv[i].阅读它

示例:

if len(sys.argv) == 3:
    decrypt(sys.argv[1], sys.argv[2])

【讨论】:

    猜你喜欢
    • 2022-09-27
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多