wlshell Commands with Examples

$variable

Displays a variable or field. Invokes a method.


Syntax:


$variable ( ()*)?

${variable} ( ()*)?

${variable.field}

Notes:

Variables can be referenced using $variable or ${variable} notations.

If the name of the variable is entered alone, it displays the current value of the variable.

If the name of a method is provided after the variable, wlshell will try to invoke the specified method on the object represented by the variable. If the method expects one or more parameters, values for those can be appended to the method name.

The invocation of a method can be used on the right side of an assignment to store the result in a variable (see examples).

The descr can be used to display the methods implemented by the object stored in a variable. See var = expr for additional information.

For more information see Working with Java Ojbects section.

This command modifies the $LAST variable. It stores the value of the variable or the value returned by the method invoked.

Examples:

#display de value of "server" variable
$server

#or
${server}
wlsh integration:/> $server
localhost:7001

wlsh integration:/> $server length
14

wlsh integration:/> i = $server indexOf ':'
variable i set to 9 (java.lang.Integer)

wlsh integration:/> host = $server substring 0 $i
variable host set to localhost (java.lang.String)
props = new java.util.Properties
$props setProperty user weblogic
wlsh [not connected]> i=10
variable i set to 10 (java.lang.Integer)

wlsh [not connected]> ${i.MAX_VALUE}
2147483647


c2w

Converts config.xml to wlshell script commands.

Syntax:

c2w [-op]

Notes:

c2w (config to wlshell) converts configuration information stored in config.xml into wlshell script commands. The file generated can be used to recreate the configuration on another domain. In the conversion process, the input config.xml file is never modified.

In addition to the normal script file, another script file is generate with commands to remove the resources created with the first file. The second file has the same name as the first file plus '.remove' as the extension.

If the destination file exists, the command will fail with a warning message, unless the -o (overwrite) option is used.

With the -p (prompt) option, c2w generates a 'prompt' command before the creation of each resource in the script file. This is useful when reading the generated script file in order to go step-by-step through the creation of resources.

c2w supports configuration files for WebLogic Server versions 6.1, 7 and 8.1.

Examples:

c2w c:/bea/user_projects/mydomain/config.xml c:/wlshell/mydomain.wlsh

c2w -o config.xml mydomain.wlsh

c2w -op config.xml mydomain.wlsh


call

Executes the specified native OS command.

Syntax:

call

Notes:

The call command executes the specified OS command. The command can include zero or more arguments. As with other commands, the output can be redirected to a file. The call command returns only when the specified command ends. The specified OS command shouldn't expect any input from the user.

After running the call command, the $LAST variable stores the exit value returned by the command. If the command didn't execute, it returns -1.

Under Windows OS, path names with directories starting with the letter 'u' need to be scaped, as \u has special meaning in Java (unicode character notation). For instance, to list directory "c:\usr", use the following syntax:

call "dir c:\\usr"

Examples:

#Windows commands
call "dir"

command = expr("copy " + ${file} + " " + ${destfile})
call $command

call "ping myserver.domain.com"

call mybatchprocess.cmd
#Unix commands
call "ls -l" > dirlisting.out
call "cat dirlisting.out"


cd


Changes or displays the current directory.

Syntax:

cd [ ]

Notes:

Changes the current directory in the current domain. If no directory is especified, it displays the name of the current directory. The command admits absolute and relative directories. The characters '/' and '\' can be used as directory delimiter. Two dots ('..') refer to the parent directory. Variables can also be used to specify a directory.

After running the cd command, the $LAST variable stores the current directory name (fully qualified).

Directory names can contain the directory delimiters '/' and '\', for instance '/JMSServer/my/server'. In this case these special character have to be escaped with the same character repeated: 'cd /JMSServer/my//server'. If the name has '\' then the escape secuence is '\\'.

If the directory name contains blank spaces or other special characters, enclose the name with double quotes (").

The cd command also supports the native object name of the MBean, by using the special "all" directory. See Accessing MBeans Using the JMX Notation section for additional information.

It is also possible to call "cd" with a variable containing an instance of "ObjecName". In that case, wlshell will change the current directory to the MBean identified by the ObjectName, under the "all" directory, in the current domain. The domain in ObjectName will be ignored.

For more information see The File System Metaphor.


Examples:

cd

cd ServerRuntime

cd ..

cd /

cd /ServerRuntime/myserver

cd \ServerRuntime\myserver

pool = /JDBCConnectionPool/myPool
cd $pool

cd /Server/$SERVER

cd "/all/name=Copy,type=GarbageCollector"

cd all
cd "type=MethodProfiler"


cd "GarbageCollector/Dynamic GC"

...

wlsh domain.com.bea:/Domain/myWDomain100> run lookupServer AdminServer
com.bea:Name=AdminServer,Type=Server

wlsh domain.com.bea:/Domain/myWDomain100> s = run lookupServer AdminServer
variable s set to com.bea:Name=AdminServer,Type=Server (javax.management.ObjectName)

wlsh domain.com.bea:/Domain/myWDomain100> cd $s
domain.com.bea:/all/Name=AdminServer,Type=Server

wlsh domain.com.bea:/all/Name=AdminServer,Type=Server>

...

ds = myDataSource

sr = run createJDBCSystemResource $ds
cd $sr
res = get JDBCResource
#res contains the ObjectName of the JDBCResource MBean related to this JDBCSystemResource
cd $res
set Name $ds


connect


Connects to a server or config file.

Syntax:

connect [-l] [ [ [ ] ] ]

Notes:

If the protocol in the server parameter is omitted, the default protocol (t3) will be used. If server, user and password are omitted, the command will use the environment variables ${server}, ${user} and ${password}, if present.

The connection can be done to an Admin Server or to a Managed Server. When connecting to an Admin Server, all the servers in the domain are availiable by opening a connection (socket) for each server in the domain. This behavior can be modified by using the -l (local) option. If the connection is made to the Admin Server using the -l option or to a Managed Server, only the MBeans registered on that server are visible through wlshell

An instance of the class "wlshell.security.Password" can be used to especify the password instead of a text value, to provide additional security in scripts. See the Protecting Passwords section for more details.

The Connectors section has specific details for each connector.


Examples:



#connecting to a running server
connect t3://localhost:7001 weblogic weblogic

server=t3://localhost:7001
user=weblogic
password=weblogic

connect

#or
connect $server $user $password

#or
connect ${server} ${user} ${password}
password_file = password.properties
password = new wlshell.security.Password
$password readPassword $password_file $user
connect $server $user $password


date

Prints the current system date.

Syntax:

date

Notes:


This command prints the current date using a java.util.Date object with a java.text.SimpleDateFormat format. The format is defined by the "dateFormat" option, which can be displayed and configured with the command: option dateFormat "yyyy/MM/dd\tHH:mm:ss".

After running the date command, the $LAST variable stores the java.util.Date object with the current date.

For more information see option.


descr


Describes an object: current value, constructors, fields and methods.

Syntax:

descr

Notes:

The descr (describe) command displays the value of the specified object, the signatures of the public constructors and methods and the fields with their value. The command takes any expression as input and describes the resulting object. This command is usually applied to variables to find out the public methods supported by the object stored in that variable, to be able to invoke a method with the right arguments.

After running the date command, the $LAST variable stores the value of the object described.


Examples:


wlsh [not connected]> props = new java.util.Properties
variable props set to {} (java.util.Properties)

wlsh [not connected]> $props setProperty user weblogic
null

wlsh [not connected]> descr $props
{user=weblogic} (java.util.Properties)

public constructors:
public java.util.Properties(java.util.Properties)
public java.util.Properties()

public fields:

public methods:
public synchronized java.lang.Object java.util.Properties.setProperty(java.lang.String,java.lang.String)
public java.lang.String java.util.Properties.getProperty(java.lang.String,java.lang.String)
public java.lang.String java.util.Properties.getProperty(java.lang.String)
(additional output suppressed)


dir


Prints contents of the current directory. Alias: ls.

Syntax:

dir [-lx] [ ]

ls [-lx] [ ]

Notes:

Lists the contents of the current directory or the provided directory.

The -l (long) option prints the contents in long format. It prints the parent name and location, if any.

The -x (JMX) option in conjuction with the -l option prints the JMX name of the MBean, when applicable.

Directory names can be relative or absolute, including domain names. It is also possible to list attributes and operations individually.

After running the dir command, the $LAST variable stores a set with the names of the elements (attributes) of the directory.

See also The File System Metaphor and Connectors .


Examples:

connect localhost:7001 weblogic weblogic

dir

ls

ls /Server

ls ..

ls ../managedServer

ls -l /ExecuteQueueRuntime

ls -lx /JDBCConnectionPool

ls -l /JMSQueue/myqueue > myqueue.txt

ls Security:/myrealmDefaultAuthenticator

ls "Security:/all/Name=myrealmDefaultAuthenticator"
wlsh integration:/JDBCConnectionPoolRuntime> ls -lx
directory of integration:/JDBCConnectionPoolRuntime

drwx integration:Location=cgServer,Name=aiPool,ServerRuntime=cgServer,Type=JDBCConnectionPoolRuntime
drwx integration:Location=cgServer,Name=bpmArchPool,ServerRuntime=cgServer,Type=JDBCConnectionPoolRuntime
drwx integration:Location=cgServer,Name=cgPool,ServerRuntime=cgServer,Type=JDBCConnectionPoolRuntime
wlsh domain.com.bea:/> ls -l "/all/Type=Domain,Name=mydomain/SecurityConfiguration"
directory of domain.com.bea:/all/Type=Domain,Name=mydomain/SecurityConfiguration

description:
Return the (new) security configuration for this domain.
attributes:
-rw- SecurityConfiguration (com.bea:Name=mydomain,Type=SecurityConfiguration)
wlsh domain.com.bea:/> ls -l /Domain/mydomain/lookupServer
directory of domain.com.bea:/Domain/mydomain/lookupServer

description:
Lookup a particular server from the list.
operations:
-r-x lookupServer (javax.management.ObjectName lookupServer(java.lang.String param1))


disconnect

Closes the current connection.

Syntax:

disconnect

Notes:


After running the disconnect command, the $LAST variable stores a Boolean value with the current connection status (true or false).

Examples:

wlsh mydomain:/> disconnect
disconnected

wlsh [not connected]>


domain:


Changes current domain.

Syntax:

:

Notes:


The current domain can be changed by specifying a domain name followed by a colon ':'. Available domains can be obtained with the 'domains' command.

After running the domain: command, the $LAST variable stores the name of the current domain.

Examples:

mydomain:

portalDomain:

Security:

java.lang:

domain.com.bea:


domains

Lists available domains.

Syntax:

domains

Notes:

The current domain can be changed by specifying a domain name followed by a colon ':'. Available domains can be obtained with the 'domains' command.

After running the domain: command, the $LAST variable stores the list of available domains.

Examples:

wlsh mydomain:/> domains
[JMImplementation, Security, WeblogicManagement, jndi@myserver, mydomain, weblogic]
Domains defined in a WebLogic version 9 Administration Server:
wlsh domain.com.bea:/> domains
[domain.JMImplementation, domain.Security, domain.com.bea, edit.JMImplementation,
edit.Security, edit.com.bea, runtime.JMImplementation, runtime.Security, runtime.com.bea]

echo

Displays messages. Alias: print.

Syntax:

echo [ ]

print [ ]

Notes:

The message can contain literals and variables. If the message contains a reserved word, it must be enclosed with double quotes (see examples).

The echo command doesn't modify the $LAST variable.

Examples:

wlsh mydomain:/> echo connected "to" server $SERVER running at $SERVER_IP
connected to server myserver running at 192.168.1.123

wlsh mydomain:/> echo Hello World!
Hello World!

wlsh mydomain:/> echo connected "to" $SERVER_URL "?" $CONNECTED
connected to t3://localhost:7001 ? true
exit

Quits wlshell. Aliases: bye, quit.

Syntax:

exit []

Notes:

The exit command quits wlshell. If there is an open connection, the connection is closed before exiting.

An optional status code can be especified. By convention, a nonzero status code indicates abnormal termination. The status code is returned to the host OS and is accessible using an environment variable (%ERRORLEVEL% in Windows and $? in Unix). The status code allows wlshell to interact with a command script.

When no status code is provided, wlshell returns 0.

Examples:

wlsh mydomain:/> exit
bye!
exit 1

error = -1
exit $error
wlsh -f bootallservers.wlsh
if %ERRORLEVEL%==1 goto error
...

explore

Opens a wlshell Explorer window.

Syntax:

explore

Notes:

Multiple Explorer windows can be opened simultaneously.

The explore command doesn't modify the $LAST variable.

For more information about the Explorer see Explorer.

Examples:

wlsh mydomain:/> explore


expr

Evaluates expressions.

Syntax:

expr ( )

Notes:

Evaluates arithmetic, relational, logical and string expressions. Expresions can have parenthesis. It is required to include at least a blank space before and after the operator.

correct: expr($a + 1)
incorrect: expr($a+1)

Arithmetic operators:

Operator Use Description
+ op1 + op2 Adds op1 and op2
- op1 - op2 Subtracts op2 from op1
* op1 * op2 Multiplies op1 by op2
/ op1 / op2 Divides op1 by op2
% op1 % op2 Computes the remainder of dividing op1 by op2

Relational operators:

Operator Use Returns true if
> op1 > op2 op1 is greater than op2
>= op1 >= op2 op1 is greater than or equal to op2
< op1 < op2 ="=" op1 ="="> a=expr(1 + 2)
variable a set to 3 (java.lang.Integer)

wlsh mydomain:/> a=expr(1 + 2.3)
variable a set to 3 (java.lang.Integer)

wlsh mydomain:/> a=expr(1.4 + 2.3)
variable a set to 3.6999999999999997 (java.lang.Double)

wlsh mydomain:/> a=expr(1.4 + 2)
variable a set to 3.4 (java.lang.Double)

wlsh mydomain:/> a=expr(3 <> a=expr(true and false)
variable a set to false (java.lang.Boolean)

wlsh mydomain:/> a=expr(true or false)
variable a set to true (java.lang.Boolean)

wlsh mydomain:/> a=expr(true and not false)
variable a set to true (java.lang.Boolean)

wlsh mydomain:/> a=expr(hello + world)
variable a set to helloworld (java.lang.String)

wlsh mydomain:/> default = expr (7001 == get /Server/myserver/ListenPort)
variable default set to true (java.lang.Boolean)


find

Searches for a string in directories.

Syntax:

find [-x]

Notes:

The find command searches for a string in directories.

Without any flag, the search is done within the directories accessible through the current key path list. With the -x flag (extended), the find command searches in all directories in the domains, even those not visible with the active key path list.

The search is not case sensitive. The search is performed in all the domains, not just the current one.

When using the "*" as the text to find, the command displays all directories in the domains.

Examples:

find jrockit
find -x jrockit

find /Server/AdminServer
find "Server=AdminServer"

find "edit.com.bea:"

find *
find -x *


for

Provides repetitive processing.

Syntax:

for in [to ] [do]
commands
end

Notes:

Sequence expressions are used in this command. A sequence can be specified with the minimum numeric value and the maximum, with a implicit increment of one. A sequence can be also specified with a value of type array or a variable that stores an array.

The for command can include other commands, including nested for commands.

The for command is a 'multiline' command, meaning that when using wlshell interactively, the user can enter more commands in different lines and finish with an 'end'. To cancel the command the user can enter 'cancel' on a new line.

After running the for command, the $LAST variable stores the last value stored in the variable.

Examples:

min=1
max=10
for ${i} in ${min} to ${max}
echo ${i}
end

dir /JDBCConnectionPoolRuntime
pools = $LAST
for $pool in $pools do
echo $pool get /JDBCConnectionPoolRuntime/$pool/ActiveConnectionsCurrentCount
end

cd /JVMRuntime/myserver
dir
attribs = $LAST
for $attr in $attribs
echo $attr "=" get $attr
end
wlsh mydomain> for $a in [server1,server2,server3]
entering multiline command, type "cancel" to cancel command

1 for $a in [server1,server2,server3]
2 > echo $a
3 > end

server1
server2
server3

wlsh mydomain> servers = [server1,server2,server3]
variable servers set to [server1, server2, server3] (java.util.ArrayList)

wlsh mydomain> for $i in 0 to 2
entering multiline command, type "cancel" to cancel command

1 for $i in 0 to 2
2 > echo $servers[$i]
3 > end

server1
server2
server3


get

Gets one or more attributes or operations.

Syntax:

get [-vrthgdm] [coordinates] [seconds] ( | )+

Notes:

More than one attribute and/or operation can be specified; in that case, the delimiter option will be printed in between two values. To customize the delimiter use the 'option' command: option delimiter "new delimiter". See option.

When applied to an operation, the get command displays the signature of the operation. The -v option provides additional information about the operation.

The -r (repeat) option displays de value of the attributes at intervals of one second. Press to finish the command. A custom pooling interval can be specified in seconds.

The -h (header) option prints the full name of the attributes in the first line. If the -t (timestamp) is also especified, the header for the timestamp column will be also printed. The header for the timestamp can be configured with the 'option' command: option dateHeader "my date header". See option.

The -t (timestamp) displays the timestamp at the time the attribute is retrieved. The format of the timestamp is defined by the "dateFormat" option, which can be displayed and configured with the command: option dateFormat "yyyy/MM/dd\tHH:mm:ss". See option.

The -g (graphic) option starts a new window to graphically display the value over time. The coordinates of the new window can also be especified in the (x, y, width, height) format. The monitor window can display any type of values (numeric, text, boolean, etc). See a screenshot.

The -d (delta) option is used in conjunction with the -g option. With this option the difference (delta) between the current value and the previous one is displayed. This is useful to graph the changes of an attribute over time, like the requests served. For instance, the following command will show the throughput of the server, as shown by the WebLogic Console:

#name for the default execute queue in 8.1
qname = weblogic.kernel.Default
get -gd /ExecuteQueueRuntime/${qname}/ServicedRequestTotalCount
The -v (verbose) option provides detailed information about the attribute or operation.

The -m (MBean) option retrieves the MBean itself so it can be assigned to a variable and used. The parameter must represent a valid MBean and should contain the type and name of the MBean. Names relative to the current directory are also valid.

The get command can also be used on the right side of an assignment, to store the value of the attribute in a variable. It can be used in general as part of an expression.

After running the get command, the $LAST variable stores the value retrieved by the command or null if the attribute doesn't exist.

Examples:

attr = /ExecuteQueueRuntime/weblogic.kernel.Default/ServicedRequestedTotalCount
get -gd $attr
get -gd (10, 0, 200, 100) $attr

cd /JDBCConnectionPoolRuntime/cgPool
get PoolState
get -r PoolState
get -rht 10 PoolState #get every 10 seconds

print "the number of active connections is: " get ActiveConnectionsCurrentCount

servermb = get -m /Server/myserver
#WebLogic version 9

#set the path key list
keys ServerRuntime Type Name

#change active domain
runtime.com.bea:

#locate the MBean
cd /AdminServer/JRockitRuntime/AdminServer

#get attribute values and redirect output to a file
get -rth FreeHeap AllProcessorsAverageLoad > freeheap.txt

#MBean names with special characters
get "runtime.com.bea:/AdminServer/ServerChannelRuntime/Default[t3]/BytesSentCount"
#WebLogic version 8.1

get -g /ServerLifeCycleRuntime/myserver/State
invoke /ServerRuntime/myserver/suspend
#see how the state change from "RUNNING" to "STANDBY" on the monitor
invoke /ServerRuntime/myserver/resume
#see how the state change from "STANDBY" to "RUNNING" on the monitor

get -v Security:/typeless/myrealmDefaultAuthenticator/createUser


help

Provides information about wlshell commands.

Syntax:

help [ ]

Notes:

The help command with no parameters displays a list of available commands and a brief description of each one. If a command name is provided, it displays additional information for that command.

This command doesn't modify the $LAST variable.

Examples:

help

help get


if

Provides conditional processing.

Syntax:

if [then]
commands
[else
commands]
end

Notes:

The expression must produce a boolean value. See expr for a description of expressions.

The if command can include other commands, including nested if commands.

The if command is a 'multiline' command, meaning that when using wlshell interactively, the user can enter more commands in different lines and finish with an 'end'. To cancel the command the user can enter 'cancel' on a new line.

This command doesn't modify the $LAST variable.

Examples:

if $CONNECTED then
echo "connected to server " $SERVER
else
echo "not connected"
end

if $CONNECTED and get /ServerRuntime/$SERVER/State == "RUNNING" then
echo "connected and server running"
else
if not $CONNECTED then
echo "not connected"
else
echo "connected, but the server is not running"
end
end

dir /Server
servers = $LAST
for $s in $servers
@ if $s == get /ServerRuntime/$s/Name
state = get /ServerRuntime/$s/State
mem = get /JVMRuntime/$s/HeapFreeCurrent
else
state = "not running"
mem = "n/a"
end
print $s get /Server/$s/ListenPort $state $mem
end


info


Displays connection, server status and local information.

Syntax:

info [-v]

Notes:

The info command displays connection information and heap size of the JVM where wlshell is running.

The -v (verbose) option provides additional information.

This command doesn't modify the $LAST variable.

Examples:

wlsh JMImplementation:/> info
connected to service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi () as user "weblogic" since Tue Dec 13 10:28:12 CST 2005

MBean Server Connection information:
- MBeanServerId: "FRANCISCO01_1134425049730"
- Specification Name: "Java Management Extensions"
- Specification Vendor: "Sun Microsystems"
- Specification Version: "1.2 Maintenance Release"
- Implementation Name: "JMX"
- Implementation Vendor: "Sun Microsystems"
- Implementation Version: "1.5.0_03-b07"
- Domains: [java.util.logging, JMImplementation, java.lang, com.jrockit]
- Default Domain: DefaultDomain
- MBeans: 14

current path keys: [type, name]

additional information:
- heap size free/total/max (MB): 56/63/127
wlsh domain.com.bea:/> info
connected to service:jmx:t3://localhost:7091 () as user "weblogic" since Mon Dec 12 21:11:31 CST 2005

Runtime MBean Server Connection information:

- MBeanServerId: "FRANCISCO01_1134061392685"
- Specification Name: "Java Management Extensions"
- Specification Vendor: "Sun Microsystems"
- Specification Version: "1.2 Maintenance Release"
- Implementation Name: "JMX"
- Implementation Vendor: "Sun Microsystems"
- Implementation Version: "1.5.0_03-b07"
- Domains: [com.bea, JMImplementation, Security]
- Default Domain: mydomain
- MBeans: 330
- Domain Prefix: runtime.

Edit MBean Server Connection information:

- MBeanServerId: "FRANCISCO01_1134061392905"
- Specification Name: "Java Management Extensions"
- Specification Vendor: "Sun Microsystems"
- Specification Version: "1.2 Maintenance Release"
- Implementation Name: "JMX"
- Implementation Vendor: "Sun Microsystems"
- Implementation Version: "1.5.0_03-b07"
- Domains: [com.bea, JMImplementation, Security]
- Default Domain: mydomain
- MBeans: 51
- Domain Prefix: edit.

Domain Runtime MBean Server Connection information:

- MBeanServerId: "FRANCISCO01_1134061424631"
- Specification Name: "Java Management Extensions"
- Specification Vendor: "Sun Microsystems"
- Specification Version: "1.2 Maintenance Release"
- Implementation Name: "JMX"
- Implementation Vendor: "Sun Microsystems"
- Implementation Version: "1.5.0_03-b07"
- Domains: [Security, JMImplementation, com.bea]
- Default Domain: mydomain
- MBeans: 628
- Domain Prefix: domain.
Default Domain: domain.com.bea

current path keys: [ServerRuntime, Type, Name]

additional information:
- heap size free/total/max (MB): 41/64/128


invoke

Invokes an operation.

Syntax:

invoke [-v] ( )*
run [-v] ( )*

Notes:

This command invokes an MBean operation. If the operation accepts one or more parameters, those can be added after the operation name.

The invoke command can also be used on the right side of an assignment, to store the value returned from the operation in a variable. It can be used in general as part of an expression.

After running the get command, the $LAST variable stores the value returned by the operation, if any, or null if the operation doesn't exist.

When an operation has the same name as a reserved word, enclose the operation name between double quotes.

Examples:

wlsh portalDomain:/> $savedom
weblogic:/Repository/Default/saveDomain

wlsh portalDomain:/> $DOMAIN
portalDomain

wlsh portalDomain:/> invoke $savedom $DOMAIN
(this operation doesn't return any value) null
invoke /ServerRuntime/portalServer/forceShutdown
auth = Security:/typeless/myrealmDefaultAuthenticator
invoke $auth/createUser spongebob password "Spongebob Squarepants"
invoke $auth/userExists spongebob
invoke $auth/createGroup cartoons "cartoons group"
Security:
cd $auth
# invoke a method and store the result in a variable
isMember = invoke isMember cartoons spongebob true
if not $isMember
invoke addMemberToGroup cartoons spongebob
end
wlshell:
cd Utils
invoke "echo" hello
invoke toUpper "hello, world!"
wlsh wlshell:/Utils> get -v addMixed
wlshell:/Utils/addMixed
operation:
name: addMixed
description:
Operation exposed for management
impact: 3
parameters: 2
param 0: name: p1, type: int
param 1: name: p2, type: java.lang.Integer
return: int
signature: int addMixed(int param1, java.lang.Integer param2)

wlsh wlshell:/Utils> run addMixed 1 2
3

wlsh wlshell:/Utils> invoke "/all/type=Utils/toUpper" hello
HELLO


mkdir


Creates a directory. Alias: md.

Syntax:

md [ ]

mkdir [ ]

Notes:

Creates a directory. The syntax and semantics of creating a directory differs between connectors. It is recommended to review the documentation of each connector:

JMX Local
JMX Remote
WebLogic Server version 9
WebLogic Server versions 6, 7 and 8
After running the mkdir command, the $LAST variable stores the fully qualified name of the directory, if this has been succesfully created. If the directory creation fails, it stores the Boolean value false.

Examples:

wlsh [not connected]> connect local://
connecting to MBeanServer in the current JVM...done

type "info" for connection information

wlsh JMImplementation:/> md wlshell:/Utils wlshell.serverside.jmx.Utils
creating wlshell:/Utils...done
wlshell:/Utils

wlsh JMImplementation:/> wlshell:

wlsh wlshell:/> cd Utils
wlshell:/Utils

wlsh wlshell:/Utils> ls
directory of wlshell:/Utils

description:

Information on the management interface of the MBean
MBean Java Class: wlshell.serverside.jmx.Utils
attributes:
Classpath () Notes ()
PID (-1) Properties ({java.runtime.name=Jav..)
Variable ()
operations:
echo (java.lang.String echo(java.l..) getProperty (java.lang.String getP..)
toUpper (java.lang.String toUpper(..)

wlsh wlshell:/Utils> set Notes "this is a note"
wlshell:/Utils/Notes
old value: (java.lang.String)
new value: this is a note (java.lang.String)

wlsh wlshell:/Utils> ls
directory of wlshell:/Utils

description:

Information on the management interface of the MBean
MBean Java Class: wlshell.serverside.jmx.Utils
attributes:
Classpath () Notes ()
PID (-1) Properties ({com.sun.management.jm..)
Variable ()
operations:
addMixed (int addMixed(int param1,..) addNatives (int addNatives(int par..)
addObjects (int addObjects(java.la..) currentDate (java.util.Date curren..)
echo (java.lang.String echo(java.l..) getProperty (java.lang.String getP..)
toUpper (java.lang.String toUpper(..)
#WLS 8.1
server = /Server/s

for $i in 1 to 3
mkdir $server$i
set $server$i/ListenPort (Integer) 7${i}01
end


option


Displays and sets current options.

Syntax:

option [ [ ] ]

Notes:

The option command with no parameters displays the current options. The options and default values are:

current options:

dateFormat (date format)=[yyyy/MM/dd HH:mm:ss]
dateHeader (date header)=[date time]
delimiter=[ ]
stopOnError=[false]
To set an option, specify the name of the option and the new value.

To display a particular option, just specify the name of the option.

Options can be customized per session by using the option command in the .wlshrc command.

The dateHeader option is used in the get -h command.

The dateFormat option is used in the get -t and date commands.

The delimiter option is used in the get command when used with more than one attribute. The delimiter goes in between values.

The stopOnError option defines whether a script will stop or continue execution when an error occurs. When true, the script will stop being executed when a command throws an error. When the option is false and an error occurs, the script execution continues and the environment variable ERROR contains the exception thrown. The default value is false.

The $LAST variable contains the value of the specified option. If no option is specified, the command doesn't modify the $LAST variable.

For more information about date formats, see java.text.SimpleDateFormat

Examples:

option dateHeader "current date time,current "
option dateFormat "yyyy.MM.dd,HH:mm:ss:S"
option dateFormat "yyyy/MM/dd HH:mm:ss"
option delimiter ","
option delimiter " "
option stopOnError false
option stopOnError true

output

Enables or disables command output and prompt.

Syntax:

output [on|off]

Notes:

When output is off, the output from commands and the prompt itself are not displayed on the console. The commands are still executed normally.

When the command is entered without parameters, it displays the current output status.

To suppress the output of just one command, the @ can be used at the begining of the line. At least one white space has to be placed after the @.

After running this command, the $LAST variable stores true if output is on or false otherwise.

Examples:

output
output off
output on

@ a=1


keys

Sets and gets the path key list. Analyzes MBean object names.


Syntax:

keys [-aA] ( )*

Notes:

The keys command displays and configures the path key list. The path key list determines how the MBeans are classified in directories and consists of a list of one or more keys. For a complete description of the path key list see the File System Metaphor section.

Without arguments, the command returns the current path key list. The path key list can be changed by specifying one or more keys as arguments. If one of the arguments is an ArrayList, the elements of the ArrayList will be added to the path key list.

With the -a flag (analyze), the keys command analyzes the MBean names in the current domain. The command provides detailed information about keys and key combinations used for MBean names to help configure the best path key list. The -A flag also performs name analysis but on all the MBeans from all domains.

The keys command can be invoked at any time, but when a connection is open, the connector might reset the path key list to a default value. See the Connectors section for connector specific information about the path key list.

The current path key list is also visible at all times on the bottom right corner of the Explorer.

After running the keys command, the $LAST variable stores the current path key list. When using the -a or -A flags, the $LAST variable stores a list with all the possible key combinations, order by the number of MBeans reachable by each one, in descending order. Therefore, $LAST[0] will contain the key combination with the highest number of reachable MBeans. This value can be used to set the path key list.

Examples:

keys

keys Type Name
wlsh runtime.sandbox:/> myKeys = [Type, Name]
variable myKeys set to [Type, Name] (java.util.ArrayList)

wlsh runtime.sandbox:/> keys $myKeys ServerRuntime
setting path keys:
- old keys: [type]
- new keys: [Type, Name, ServerRuntime]
keys -A
k = $LAST
keys $k[0]
wlsh java.lang:/> keys -A
current path keys: [type, name]

MBeans analysis for all domains:

number of MBeans: 16
reachable with current path keys: 16
exact match: 8
fewer keys: 8
out of reach: 0

keys and frequency:
name = 8
type = 16

number of keys and frequency:
1 = 8
2 = 8

analyzing key combinations..done
key combinations and frecuency (Sorted):
[name, type]
reachable MBeans: 8
exact match: 8
fewer keys: 0
out of reach: 8
[type]
reachable MBeans: 8
exact match: 8
fewer keys: 0
out of reach: 8


ping

Pings the specified server.

Syntax:

ping [ [ [ ] ] ]

Notes:

The ping command can be used to test the connectivity from wlshell to the WebLogic Server running at the specified server URL.

After running the ping command, the $LAST variable stores true if a response from the server is received and false otherwise.

An instance of the class "wlshell.security.Password" can be used to especify the password instead of a text value, providing additional security in scripts. See the Protecting Passwords section for more details.

Examples:

wlsh [not connected]> ping localhost:7001 weblogic weblogic
pinging t3://localhost:7001 as weblogic...done

Reply from t3://localhost:7001 bytes=64 time=15ms
Reply from t3://localhost:7001 bytes=64 time<1ms bytes="64" server =" localhost:7001" user =" weblogic" password_file =" password.properties" password =" new" server =" prompt" user =" prompt" password =" prompt" exp =" prompt"> pwd
portalDomain:/JMSServerRuntime/cgJMSServer


read

Reads and executes the commands in the specified script file.

Syntax:

read

Notes:

This command first validates the syntax of the commands in the script file, if the syntax is valid then the commands in the file are executed. If the script file has syntax errors then an error message is displayed with the line and column number indicating where the syntax error is and the script is not executed.

The last line of the script file must end with an "end-of-line" character ('\n').

Examples:

read c:/wlshell/scripts/status.wlsh

reconnect

Reconnects to the current server(s).

Syntax:

reconnect

Notes:

The reconnect command remembers the current connection URL, credentials (user name and password) and working domain and directory; it then closes the current connection and opens a new one using the previous URL and credentials; it finally changes the current domain and working directory to the ones before.

It is useful when shuting down the server from wlshell and restarting it again from the command line. In that case, the reconnect command will reopen the communication to the server without having to provide again the URL and credentials. It is also useful when one of the servers in the domain is no longer available and being able to reopen the connections to only the running servers.

This command can be executed from the command line and from the Explorer.

After running the disconnect command, the $LAST variable stores the current working domain and directory.

Examples:

connect
cd JDBCConnectionPool
reconnect


reload

Reloads information from the server(s).

Syntax:

reload

Notes:

The reload command updates the information about the server(s) of the current connection. In most cases, wlshell queries the server(s) for information when requested by the user. For instance, when listing the content of a type directory, the shell queries the server(s) for the MBeans of that type. In other cases, the shell stores some information that at some point may not represent what is on the server, mainly the list of available MBean types. If another wlshell instance or a web-based console creates a new resource of a new type, that type is not available on the current shell unless the local list of types is recreated with the reload command.

This command can be executed from the command line and from the Explorer.

After running the disconnect command, the $LAST variable stores a Boolean value with true if it was successful or false otherwise.

Examples:

reload


rmdir


Removes a directory. Alias: rd.

Syntax:

rd

rmdir

Notes:

Removes a directory. On a regular domain (JMX domain), the first level directories represent MBean types and the second level represent MBeans. When removing a first level directory (e.g. /JMSQueue), wlshell removes an MBean type only, provided there are no MBeans of that type (subdirectories). When removing a second level directory (e.g. /JMSQueue/myQueue), the specified MBean is removed from the server. The name of the deleted MBean is the name provided in the command and its type is the name of the parent directory.

On WebLogic, the deletion of an MBean of a particular type causes the removal of the corresponding resource from the domain. In the example, deleting the /JMSQueue/myQueue directory will cause WebLogic Server to destroy the JMS Queue with name 'myQueue'.

After running the rmdir command, the $LAST variable stores the fully qualified name of the removed directory, if this has been succesfully removed. If the directory deletion fails, it stores the false Boolean value.

Examples:

rmdir /JMSQueue/myQueue

set

Sets an attribute or displays environment variables.

Syntax:

set [-v] [ ]

Notes:

The set command performs two distinct functions. With no arguments, the set command displays the current wlshell variables and their values. If the -v is provided, the command also displays the class name for the objects stored in the variables.

When the name of an MBean attribute (absolute or relative path) and a value is provided, the set command will try to set the attribute to that value. Null values can be used (null).

An instance of the class "wlshell.security.Password" can be used to especify the password instead of a text value, to provide additional security in scripts. See the Protecting Passwords section for more details.

After running the set command with arguments, the $LAST variable stores value set in the attribute.

Examples:

set
set -v

set ListenPort 80

set /JDBCConnectionPool/cgPool/Properties $props
wlsh myDomain:/> dbpass = new wlshell.security.Password
variable dbpass set to (wlshell.security.Password)

wlsh myDomain:/> $dbpass readPassword password.properties dbuser
true

wlsh myDomain:/> set /JDBCConnectionPool/cgPool/Password $dbpass
myDomain:/JDBCConnectionPool/cgPool/Password
old value: weblogic (java.lang.String)
new value: cd Server/$SERVER
sandbox:/Server/myserver

wlsh sandbox:/Server/myserver> set StdoutDebugEnabled true
sandbox:/Server/myserver/StdoutDebugEnabled
old value: false (java.lang.Boolean)
new value: true (java.lang.Boolean)

wlsh sandbox:/Server/myserver> set StdoutSeverityLevel 64
sandbox:/Server/myserver/StdoutSeverityLevel
old value: 32 (java.lang.Integer)
new value: 64 (java.lang.Integer)

wlsh sandbox:/Server/myserver> set Notes "this is my server"
sandbox:/Server/myserver/Notes
old value: null (null)
new value: this is my server (java.lang.String)

wlsh sandbox:/Server/myserver> set Notes null
sandbox:/Server/myserver/Notes
old value: this is my server (java.lang.String)
new value: null (null)


sleep


Sleeps for the specified milliseconds.

Syntax:

sleep

Notes:

This command makes wlshell to sleep for the specified number of milliseconds. If there are Explorers or Monitors open, the sleep command will not have any effect on them, and they will continue operating without any pause.

After running the sleep command, the $LAST variable stores the number of milliseconds slept.

Examples:

#sleep for one second
sleep 1000

#sleep for one minute
wlsh [not connected]> millis = 1000
variable millis set to 1000 (java.lang.Integer)

wlsh [not connected]> sleep expr (60 * $millis)

upload

Uploads a local file to the server's filesystem.

Syntax:

upload []

Notes:

This command copies a file from the wlshell's local filesystem to the Admin server's filesystem. It is useful when deploying applications on a remote server. The application must be in EAR/JAR/WAR file format and can be uploaded to the Admin server for deployment. After running successfully the command, it will display the full path of the uploaded file.

This command only applies when connecting to an Administration server. By default, the location of the uploaded file follows this rule:

/directory-of-the-domain/name-of-the-admin-server/upload/filename/filename.ext
If the remote subdirectory is specified, then it is used instead of the filename:

/directory-of-the-domain/name-of-the-admin-server/upload/remote-subdirectory/filename.ext
The upload command doesn't allow absolute path names, but it is possible to change the default root directory for uploading files. The directory is specified by the UploadDirectoryName attribute of the server. To change it, use the set command, for instance:

set /Server/myserver/UploadDirectoryName c:/temp
After running the upload command, the $LAST variable stores the full path of the uploaded file, if it was successful. It will have "null" otherwise. The remote file name stored in $LAST can be used to specify the application to deploy using the DeployerRuntime MBean.

The upload command is provided with the WebLogic connectors. The generic JMX connectors don't support this feature. When working with JMX, use other means to copy the deployment files to the remote machine (e.g. ftp or scp).

Examples:

wlsh sandbox:/> upload c:/bea812/weblogic81/samples/domains/ (next line)
examples/applications/ejb20_basic_statelessSession.ear

file successfully uploaded, remote file is: D:\user_projects\ (next line)
domains\sandbox\.\portalServer\upload\ejb20_basic_statelessSession\ (next line)
ejb20_basic_statelessSession.ear
upload c:/bea812/weblogic81/samples/domains/examples/applications/ (next line)
ejb20_basic_statelessSession.ear

appfile = $LAST
#the $appfile value can be used for deployment
if $appfile != null
invoke ${deployer}/activate $appfile $appname null $data null
end


varexpr

Assigns a value to a variable.

Syntax:

[] =

[] = new []

Notes:

Variables in wlshell are dynamically created and initialized with the assign command. A valid expression can be used to initialize a variable with a value.

A variable can also be initialized with a new object of a particular class by using the "new" keyword and the fully qualified name of the class. The package can be omitted for classes of the "java.lang" package.

When creating a new object, if the constructor requires one or more arguments, it is possible to specify their values after the name of the class.

It is possible to create arrays of a particular class by specifying the length of the array enclosed by square brackets (see examples). It is also possible to modify a particular array element by specifying the name of the array variable and the index enclosed by square brackets.

The set can be used to display the defined variables and their values.

After running this command, the $LAST variable stores the value of stored in the specified variable.

Examples:

wlsh sandbox:/> server = t3://myserver.domain.com:7001
variable server set to t3://myserver.domain.com:7001 (java.lang.String)
wlsh sandbox:/> servers = new java.util.Properties
variable servers set to {} (java.util.Properties)

wlsh sandbox:/> a = new String hello
variable a set to hello (java.lang.String)

wlsh sandbox:/> a = new Integer 10
variable a set to 10 (java.lang.Integer)
wlsh sandbox:/> servers = new String[5]
variable servers set to [null, null, null, null, null] (array)

wlsh sandbox:/> servers[0] = server0
variable servers[0] set to server0 (java.lang.String)

wlsh sandbox:/> for $i in 0 to 4
entering multiline command, type "cancel" to cancel command

1 for $i in 0 to 4
2 > servers[$i] = server$i
3 > end

variable servers[0] set to server0 (java.lang.String)
variable servers[1] set to server1 (java.lang.String)
variable servers[2] set to server2 (java.lang.String)
variable servers[3] set to server3 (java.lang.String)
variable servers[4] set to server4 (java.lang.String)

wlsh sandbox:/> $servers
[server0, server1, server2, server3, server4]


ver

Prints wlshell version.

Syntax:

ver

Notes:

The ver command displays the current wlshell and connectors version. It also displays the version of the WebLogic libraries being used and the JVM version.

After running the ver command, the $LAST variable stores the numeric value of the current wlshell version.

Examples:

wlsh [not connected]> ver

wlshell version 2.1.0

Java version:
BEA Systems, Inc., BEA JRockit(R), version R26.4.0-63_CR302700-72606-1.5.0_06-20061127-1108-win-ia32

Connectors:

protocols: local
provider: wlshell.connect.jmx.LocalConnector
version: wlshell Local JMX Connector version 2.1.0 for JMX 1.2 and higher

protocols: service:jmx:rmi
provider: wlshell.connect.jmx.RemoteConnector
version: wlshell Remote JMX Connector version 2.1.0 for JMX 1.2 with JMX Remote API 1.0

protocols: http, https, service:jmx:t3, t3, t3s
provider: wlshell.connect.jmx.weblogic.Connector
version: wlshell Connector version 2.1.0 for WebLogic 6.1, 7.0, 8.1, 9.2 and 10
Using WebLogic libraries:
WebLogic Server 10.0 SP0 Wed May 9 18:10:27 EDT 2007 933139


while

Provides repetitive processing.

while [do]
commands
end

Notes:

The while expression can be any expression that produces a boolean value.

The for command can include other commands, including nested for commands.

The while command is a 'multiline' command, meaning that when using wlshell interactively, the user can enter more commands in different lines and finish with an 'end'. To cancel the command the user can enter 'cancel' on a new line.

After running the while command, the $LAST variable stores the last value stored in the variable.

Examples:

wlsh [not connected]> a=4
variable a set to 4 (java.lang.Integer)

wlsh [not connected]> while $a >= 0
entering multiline command, type "cancel" to cancel command

1 while $a >= 0
2 > a = expr($a - 1)
3 > end

variable a set to 3 (java.lang.Integer)
variable a set to 2 (java.lang.Integer)
variable a set to 1 (java.lang.Integer)
variable a set to 0 (java.lang.Integer)
variable a set to -1 (java.lang.Integer)

0 Response to "wlshell Commands with Examples"

Post a Comment

Powered by Blogger