6 Replies Latest reply: Mar 20, 2013 3:50 PM by Olaf Heimburger RSS

    Passing arguments in a .py script

    008
      I have a .py script which starts with a "connect()" statement. Whenever I run it, I need to give username, password & server URL manually.
      But I want to make this script non-interactive. At the same time, I don't want to make any change to the original script. Is there any method
      to pass those three arguments at the first place or read from any property file?

      Thanks in Advance.
        • 1. Re: Passing arguments in a .py script
          Olaf Heimburger
          http://www.jython.org/jythonbook/en/1.0/Scripting.html
          • 2. Re: Passing arguments in a .py script
            René van Wijk
            "... or read from any property file?"

            http://docs.oracle.com/cd/E23943_01/web.1111/e13813/reference.htm#i1155751

            or in the command-line

            ${MIDDLEWARE_HOME}/common/bin/wlst.sh -loadProperties ${SCRIPT_PATH}/environment.properties ${SCRIPT_PATH}/create_environment.py

            http://middlewaremagic.com/weblogic/?p=8260
            • 3. Re: Passing arguments in a .py script
              008
              Thanks for your reply Rene.
              The above method will work as long as we have variables inside 'connect()' statement [e.g. connect(username,password,serverurl)]. Then we can set those variables in properties file & load it before script execution.
              But in my script I have connect() statement at the beginning & I can't modify the script.
              Is there any method to make my script non-interactive.

              Edited by: 008 on Mar 20, 2013 10:21 PM
              • 4. Re: Passing arguments in a .py script
                Olaf Heimburger
                connect() without parameters defaults to weblogic, Welcome1, t3://localhost:7001. This is not a dynamic way of connecting to the AdminServer.
                --olaf                                                                                                                                                                                                                                                                                                           
                • 5. Re: Passing arguments in a .py script
                  008
                  Thanks for your update Olaf.

                  Whenever I am running my 'sample.py' script, the script is asking for these three inputs.

                  Please enter your username :
                  Please enter your password :
                  Please enter your server URL [t3://localhost:7001] :

                  I want to pass these arguments with my sample.py script in a single command.
                  Is it possible?
                  • 6. Re: Passing arguments in a .py script
                    Olaf Heimburger
                    Instead of repeating all options, check the WLST Command Reference Guide : http://docs.oracle.com/cd/E23943_01/web.1111/e13813/reference.htm#i1005916
                    --olaf