Question

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.

Was it helpful?

Solution 2

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

OTHER TIPS

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://"

I wanted for it to only show me lines that I print inside the script, so I did it simple - prepended special char sequence to all lines I wanted to see in logs (it was print('--> ...') in my case) and launched it like that:

wlst.sh changePassword.wlst.py "$@" | grep -- "-->"

Sample output:

Executing WLST script for domain SampleDomain
--> Executing credential change for SampleDomain
--> Changing DB password for DSTYPE1
--> Changing password for DataSource SampleDS1
--> Successfully changed DB credentials!
--> Changing password for DataSource SampleDS2
--> No JDBC resource with name SampleDS2 found, skipping...
--> Changing password for DataSource SampleDS3
--> No JDBC resource with name SampleDS3 found, skipping...
--> Changing password for DataSource SampleDS4
--> Successfully changed DB credentials!
Completed execution for domain SampleDomain

Bit of a long shot but you could also silence the entire JVM output by capturing stdout and stderr into a different stream and then print values captured from the weblogic mbeans to the console streams. I had to do something similar a while back after writing an ansible module which required me to return pure JSON to stdout without any message banners or other stuff printed to the terminal.

A possible solution for your needs would involve writing a python script that first changes the OutputStreams as in this example and then starts a WSLT session. Just remember to keep a "copy" of the console out streams and use these to write your results to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top