6

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.

Martin Nielsen
  • 1,865
  • 6
  • 30
  • 54
  • Why exactly do you need to get rid of this? Wouldn't it be simple to just redirect all output to a file e.g. `java weblogic.WLST > ./mylog.log` – Display Name is missing Feb 17 '14 at 16:02
  • I need the output of the python script redirected into a calling shell script. I do not need the startup message, its just clutter i have no need for. I guess i could sed or grep my way out of it, but that is a hack that will earn me a one way ticket to developer hell... :) – Martin Nielsen Feb 18 '14 at 08:52
  • First statement of your python script can be redirect(myWlstLogFile). Where myWlstLogFile is the log file location where you want your wlst code to write the log to. The log file loc can be passed as a parameter to your python script. [Check this](http://docs.oracle.com/cd/E24329_01/web.1211/e24490/reference.htm#autoId275) – Mani Feb 19 '14 at 06:22
  • I already did that. That does not remove the welcome message from the interpreter however. – Martin Nielsen Feb 19 '14 at 11:07
  • Hi Martin, did you tried using << operator for a file redirection which I have illustrated http://wlstbyexamples.blogspot.in/2009/05/how-to-store-output-of-wlst.html – PavanDevarakonda Feb 24 '14 at 09:10
  • That would do me no good. The point is that i need all the output, except the welcome message. Redirecting to another source would not do anything except move the problem. – Martin Nielsen Feb 24 '14 at 13:19
  • 1
    @MartinNielsen, did you ever find a solution to this? I am trying to do the same for a python based wlst script which we want to run with watch command... the wlst output logs are messing the watch output up! We are not interested in redirecting logs to files or anything like that so those solutions are no good... – Going Bananas Feb 03 '16 at 14:02

4 Answers4

3

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

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
  • 1
    This one is quite nice. I did it with egrep. Removes all not necessary lines from both head and tail of regular WLST output. /oracle/fmwhome/oracle_common/common/bin/wlst.sh wls_soa_dms.wlst -c 2 -d 2 | egrep -v 'CLASSPATH|Initializing WebLogic Scripting Tool|Welcome to WebLogic Server Administration Scripting Shell|Type help\(\) for help on available commands|Connecting to|Successfully connected to|Warning: An insecure protocol was used to connect to the|To ensure on-the-wire security|Admin port should be used instead|Disconnected from weblogic server|Exiting WebLogic Scripting Tool|^$' – Ryszard Styczynski Jan 04 '18 at 09:52
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

  • That is pretty elegant. I think i actually might exchange my own hack for this. I have a sed command in every script right now :) – Martin Nielsen Feb 22 '16 at 12:50
  • I'm trying to pipe it through `tail +7` instead of sed. I'm still getting some blank lines in middle, though, so I might need sed to get rid of them. It's sad that there is still no silent mode for WLST startup. – Menachem Jun 15 '16 at 01:41
2

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
Kanedias
  • 386
  • 5
  • 7
0

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.

Niels
  • 77
  • 1
  • 9