The wsadmin utility can be used to perform a wide variety of administrative tasks. Use the following command to start the wsdamin utility.
Username / Password
If you are using federated or LDAP repositories, you will be prompted to provide a username and password. Enter the username and password of an administrative user.
Or, the username and password can be provided on the command line.
~]# /opt/IBM/WebSphere/your_server_name/profiles/your_profile_name/bin/wsadmin.sh -user root -password your_password
The prior options are not ideal, as the username and password provided are visible using the ps command.
~]# ps -ef | grep java . . . com.ibm.ws.admin.services.WsAdmin -user root -password your_password
The username and password can be entered in the was_home/profiles/profiles/properties/soap.client.props file for SOAP connections.
com.ibm.SOAP.securityEnabled=true com.ibm.SOAP.loginUserid=your_username com.ibm.SOAP.loginPassword=your_password com.ibm.SOAP.loginSource=none
Or, the username and password can be entered in the was_home/profiles/profiles/properties/sas.client.props file for RMI or JSR160RMI connections.
com.ibm.CORBA.loginUserid=your_username com.ibm.CORBA.loginPassword=your_password com.ibm.CORBA.loginSource=properties
Or, the username and password can be entered in the was_home/profiles/profiles/properties/ipc.client.props file for IPC connections. You will also comment out the login source line.
com.ibm.IPC.loginUserid=your_username com.ibm.IPC.loginPassword=your_password # com.ibm.IPC.loginSource=prompt
Language (Jacl, Jython)
The wsadmin utility uses to different languages, Jacl or Jython. You can specify the language you want to use.
~]# /opt/IBM/WebSphere/your_server_name/bin/wsadmin.sh -lang jacl ~]# /opt/IBM/WebSphere/your_server_name/bin/wsadmin.sh -lang jython
If you don't specify a language, either Jacl or Jython will be used. By default, Jython is the default language, which is specified in the wsadmin.properties file.
Once connected to the wsdamin console, there will be a wsadmin> prompt, where you can enter a command. Following is an example of the same command issued in Jython and Jacl.
# Jython wsdamin>AdminTask.searchUsers # Jacl wsdamin>$AdminTask searchUsers
Scripting Objects - ( AdminConfig, AdminControl, AdminApp, AdminTask )
Wsadmin commands have a structure of Scripting Object - Command - Attributes. For example, in the following samples, AdminConfig is the scripting object, attributes is the command, and ApplicationServer is the attribute.
# Jython wsadmin> print AdminConfig.attributes('ApplicationServer') # Jacl wsadmin> $AdminConfig attributes ApplicationServer
There are 4 scripting objects that can be used.
The AdminConfig, AdminApp, and AdminTask scripting objects are used to interact with a configuration object, and the AdminControl is used to interact with a runtime object. For example, if you want to check the status of an application server, such as running or stopped, you would use AdminControl, since an application server status is runtime. Since AdminControl is used against runtime, the AdminControl has no impact on persistant configuration.
One of the most frequently used AdminConfig commands is save. This saves a change to the master repository.
# Jacl $AdminConfig save # Jython AdminConfig.save()
Generate commands from the WebSphere admin console
One of the most useful features of the WebSphere admin console is the consoles ability to create wsadmin commands for you. For example, lets say you want to determine the wsadmin command to restart one of your JVMs. To do this, you would sign into the WebSphere admin console, and then restart the JVM. Then, on the right side of the admin console, select "View administrative scripting command for last action." A pop-up box will be displayed with the wsadmin command.
Run commands in-line
By default, the wsadmin command will start a user interface where you can type in a command. The -c option can be used to instruct the wsadmin command to run a command instead of being prompted to enter a command. In this example, the AdminApp.view command is executed in a single command.
~]# wsadmin.sh -c "print AdminApp.view('myApp')"
Run Python script
The -f option is used to run another script, such as a Python script.
~]# wsadmin.sh -f example.py