WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 03:42 AM
    Hello All,

        I am in process of writing a jython script which stops and starts the specific cluster.The cluster name need to pass through argument.
    The issue is cluster name in cutomer environment consists of two word and that is why it consists of white space e.g "Reporting Cluster".
    How can i pass the name in single argument, Please help.
    Please feel free if you have any futher questions, i will try to elaborate the issue.

    Thanks,
    Saurabh.


  • 2.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 05:24 AM
    Hi Saurabh

      put in quotes the argument
     
      and example
     
      wsadmin.bat -conntype NONE -f PATH_TO_SCRIPT\argu.py one "Reporting Cluster" three
     
      and the script argu.py has the next content:
     
      import sys

      argu1 = sys.argv[0]
      argu2 = sys.argv[1]
      argu3 = sys.argv[2]

      print "1º argument: " + argu1
      print "2º argument: " + argu2
      print "3º argument: " + argu3
     
      or the next one
     
      import sys
      for arg in sys.argv:
        print arg
        
      Hope this helps. Tell us if you need more support.
     
    Regards


  • 3.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 07:59 AM
    HI Gabriel,

       I put argument in quotes, but it did not work, I am getting below error:

    WASX7017E: Exception received while running file "StartCluster.py"; exception information: com.ibm.bsf.BSFException: exception from Jytho
    Traceback (innermost last):
      File "", line 16, in ?
    IndexError: index out of range: 0

    My Script is as follow :


    def getListArray(l):
        return l.splitlines()
       
    cellName='maximoCell'


    clusters = AdminConfig.list('ServerCluster')


    def GetHostNameByNode(nm):
     hostNodeList = AdminConfig.list("Node")
     for hostNode in getListArray(hostNodeList):
      hostNodeNodeName = AdminConfig.showAttribute(hostNode, "name")
      if hostNodeNodeName == nm:
       HostNameByNode = AdminConfig.showAttribute(hostNode, "hostName")
       return HostNameByNode


    cluster_name=sys.argv[0]
    aCluster = AdminConfig.getid('/ServerCluster:' + cluster_name + '/')
    serverList = AdminConfig.list('ClusterMember', aCluster)
       
    for aServer in getListArray(serverList):
         sName = AdminConfig.showAttribute(aServer, 'memberName')
         nName = AdminConfig.showAttribute(aServer, 'nodeName')
         bServer = AdminControl.completeObjectName('cell=' + cellName + ',node=' + nName + ',name=' + sName + ',type=Server,*')
              aState = AdminControl.getAttribute(bServer, 'state')  
       if (len(bserver) > 0):
                          hostName = GetHostNameByNode(nName)
                                    print "\tServer Name %s on Node %s is started on Host %s" % (sName, nName, hostName)
                                   
              else:
            print "\tStarting Server Name %s on Node %s (sName, nName)"
                      result = AdminControl.startServer(sName,nName)
                      print result
       
             
       



  • 4.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 08:10 AM
    Saurabh,

      Have you do the import sys?

      The problem is in line 16:

        cluster_name=sys.argv[0]

      Put import sys in your script.

    regards


  • 5.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 09:20 AM
    Hi Gabriel,

      Thanks for your quick reply, even after "import sys", I am getting the same error.


  • 6.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 10:45 AM
    Hi Saurabh,

    Still you are facing the issue ?

    Can you try below..

    Resolving the problem



    Add a backslash character ( \ ) before each double quotation character in your event selector string.



    Here I got this info..
    www-01.ibm.com/support/docview.wss?uid=s...



  • 7.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 10:45 AM
    Saurabh,

      Have you test my examples? are they working in your environment?

      I'm trying to execute your script in my environment and I have had some problems with the indention of the script inside the for loop section.

    regards


  • 8.  to pass a argument in jython script which has white spaces

    Posted 01/17/14 11:57 AM
    Saurabh,

      Which WAS version are you using?

      from version 7 you have the scriptlibrary in:

      \scriptLibraries

      And in server\V7\ you have an script to manage the servers and clusters

      about your script:

      1.- Review indentation at for section

      2.- When you use AdminControl.completeObjectName the "object" need to be running in your case the cluster members must be up and running to get their complet objectName.  So if the servers are up and running your cluster is up and running!!!!

      Performing operations on running objects using the wsadmin tool
      pic.dhe.ibm.com/infocenter/wasinfo/v6r1/...


    regards


  • 9.  to pass a argument in jython script which has white spaces

    Posted 01/22/14 03:49 AM
    Hi Gabriel,

    When i used the script you have given, i got the same error:

    WASX7209I: Connected to process "dmgr" on node maximoCellMgr using SOAP connector;  The type of process is: DeploymentManager
    WASX7017E: Exception received while running file "C:\Users\mthimmegowd-gcsadmin\Documents\org.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
      File "", line 3, in ?
    IndexError: index out of range: 0


  • 10.  to pass a argument in jython script which has white spaces

    Posted 01/23/14 05:00 AM
    Saurabh,

      the thread starts "The cluster name need to pass through argument. The issue is cluster name in cutomer environment consists of two word and that is why it consists of white space e.g "Reporting Cluster".
    How can i pass the name in single argument, Please help."

      If I launch the next (dummy) script (argu.py)
     
       import sys

       argu1 = sys.argv[0]
       argu2 = sys.argv[1]
       argu3 = sys.argv[2]
       
       print "1º argument: " + argu1
       print "2º argument: " + argu2
       print "3º argument: " + argu3
     
       WITHOUT parameters I have the next message

       wsadmin.bat -conntype NONE -f C:\gabi\argu.py
       
        WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
        WASX7017E: Exception received while running file "C:\gabi\argu.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
        Traceback (innermost last):
        File "", line 3, in ?
        IndexError: index out of range: 0   
     
       the same script passing parameters
       
       wsadmin.bat -conntype NONE -f C:\gabi\argu.py one two three
       
        WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
        WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable:"[one, two, three]"
        1º argument: one
        2º argument: two
        3º argument: three   
        
       and the same script passing parameter who has two words in single parameter
       
       wsadmin.bat -conntype NONE -f C:\gabi\argu.py one "two words" three

        WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
        WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[one, two words, three]"
        1º argument: one
        2º argument: two words
        3º argument: three


    Hope this helps,

    regards