bash to python calling wlst and passing parameters

500 Views Asked by At

I am something of a beginner with python so I am writing bash script wrapper that passes some arguments to wlst - jython script that reads these values.

for example:

./serverArgUpdate.sh myAdminServer 40100 'server_MS1, server_MS2' -Dweblogic.logs2=debug

However, in my WLST script I read the values but having issue with arg value 4 == server_MS1, server_MS2

    import sys
###  Domain Properties  ####
adminURL                = sys.argv[1]
domainUserName          = sys.argv[2]
domainPassword          = sys.argv[3]
svrName                 = str(sys.argv[4])
print("The server names are "+svrName)
setarg                  = sys.argv[5]
###############     Connecting to AdminServer     #################################

def connectAdmin() :
 try:
  connect(userConfigFile=domainUserName,userKeyFile=domainPassword,url=adminURL)
 except:
  banner('Unable to find admin server..')
  exit()

def banner(line):
      print('='*80)
      print(line)
      print('='*80)
      
########################################################################

def updateSvrArg():
  for i in svrName:
    cd('/Servers/'+i+'/ServerStart/'+i)
    ...

###############     Main Script   #####################################
if __name__== "main":
  try:
    updateSvrArg() 
    disconnect()
  except:
    dumpStack()
    banner("There was an error with the script: Check the properties file or check if Someone has the lock/edit on the console")
    cancelEdit(defaultAnswer='y')
    exit(exitcode=0)
    sys.exit(1)

While executing

wlst.sh serverArgUpdate.py t3://myAdminServer:40100 systemKeys/system_dev.config systemKeys/system_dev.key server_MS1,server_MS2 -Dweblogic.logs=debug

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

The server names are server_MS1
Error: No domain or domain template has been read.
Error: No domain or domain template has been read.
========================================
The server name is s
========================================

basically should read svrName=('server_MS1','server_MS2') to work

how do I pass 'server_MS1','server_MS2' to svrName variable from the bash script to wlst?

any help much appreciated.

0

There are 0 best solutions below