This section describes some topics related to the wlshell script language. The Working with Java Objects section contains detailed information on how to use Java objects. For a description of the syntax, see the BNF document.
wlshell considers a comment anything that goes after the pound sign, # (shell-like comment) or double forward slash, // (java-like comment). For example:
#this is a comment a = 10 # initialize variable for $i in 1 to $a #for loop echo $i # print the value end //this is the final comment
Variables in wlshell can be defined by simply initializing them with a value. For example:
address=10.2.3.123
Variables can be referenced using $variable or ${variable} notations. For example:
connect $address:7001
connect ${address}:7001
Defined variables can be displayed with the "set" command. For example:
set set -v
The output of any command can be redirected to a file. When using the > character, the output will be sent to the specified file and if the file already exists the content is overwritten with the new output. When using >>, the output is appended to the end of the file. Examples:
get -rht attr attr > file.txt get -rht attr attr >> file.txt file = /mydir/myfile.txt ls -l /Server > $file
In general, values can be concatenated just by putting one after another, for example:
wlsh [not connected]> i = 1
variable i set to 1 (java.lang.Integer)
wlsh [not connected]> q = queue$i
variable q set to queue1 (java.lang.String)
...
wlsh domain.com.bea:/> server=AdminServer
variable server set to AdminServer (java.lang.String)
wlsh domain.com.bea:/> cd /Server/$server
domain.com.bea:/Server/AdminServer
Strings, and values in general, can also be concatenated using the "expr" command with the "+" operator. For example:
i = 1
q = expr("queue" + $i)
username = weblogic
props = expr("user=" + $username)
See expr command for more information.