Search code examples
weblogicwlst

Running the WLST interpreter silently


I am trying to figure out a way to make the weblogic WLST terminal run in silent mode. When i start the terminal with the java weblogic.WLST command, it prints the lines:

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Is there a command line flag or some unknown witchcraft to make the interpreter not write these lines? I wishfully tried -s for silent, to no avail. And all my googling lead me to an -i flag that does something completely different.

EDIT:

To clarify my purpose:

I need the interpreter to run a python script, and i do need the output from that. The welcome message is useless clutter however, that i would like to be rid of.

Limited to:

The only problem i have is the first lines written by the interpreter itself. Once inside the python script i have no problem handling what send to the output. My only problem is the welcome lines written above. These are written by the interpreter itself, and not the python code.


Solution

  • Try this:

    Like you said "it's a hack", but it's a fairly elegant hack.

    Create the file runwlst.sh:

    #!/bin/bash
    . ${WLS_HOME}/server/bin/setWLSEnv.sh >/dev/null 2>&1
    FILENAME=$1
    shift
    java weblogic.WLST ${FILENAME} "$@" | sed -e "1,7 d"
    

    WLS_HOME needs to be set, or use the absolute path to setWLSEnv.sh.

    Then create your WLST scripts as "shell" scripts like so (I like to use the ".wlsh" extension for my scripts):

    #!/bin/bash /absolute_path_to_runwlst.sh/runwlst.sh
    # your WLST Python code starts here
    import ...
    

    This obviously the sed script used in runwlst.sh only works if the "Initializing" banner is 7 lines long, which could change with new releases or patches of WLS.

    The benefit of this solution is that now you can just run your WLST scripts from the command line like so:

    $ createManagedServer.wlsh domain servername 
    

    Or use WLST scripts is other shell scipts like so:

    #!/bin/bash
    PORT=`./getPortForManagedServer.wlsh domain server`
    echo ${PORT}
    

    you get the picture