Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running the WLST interpreter silently

Tags:

weblogic

wlst

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.

like image 480
Martin Nielsen Avatar asked Feb 17 '14 14:02

Martin Nielsen


2 Answers

To solve the problem, I did something little differente.. I put a grep -v in the output .. like this:

java weblogic.WLST script.py $ARGS | grep -v "Initializing WebLogic Scripting Tool (WLST) ..." | grep -v "Welcome to WebLogic Server Administration Scripting Shell" | grep -v "Type help() for help on available commands" | grep -v "Successfully connected to Admin Server \"AdminServer\" that belongs to domain \"domain\"." | grep -v "Warning: An insecure protocol was used to connect to the server." | grep -v "To ensure on-the-wire security, the SSL port or Admin port should be used instead." | grep -v "Location changed to domainRuntime tree. This is a read-only tree" | grep -v "with DomainMBean as the root MBean." | grep -v "For more help, use help('domainRuntime')" | grep -v "Successfully connected to Admin Server" | grep -v "Connecting to t3://"

like image 50
Patrick Muller Avatar answered Oct 14 '22 12:10

Patrick Muller


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

like image 32
Kenneth Copeland Avatar answered Oct 14 '22 11:10

Kenneth Copeland