Sei sulla pagina 1di 64

BEA WebLogic

Server

Using the WebLogic Server Scripting Tool

Release 2 Revised: April 27, 2004

Copyright
Copyright 2003 BEA Systems, Inc. All Rights Reserved.

Restricted Rights Legend


This software and documentation is subject to and made available only pursuant to the terms of the BEA Systems License Agreement and may be used or copied only in accordance with the terms of that agreement. It is against the law to copy the software except as specifically allowed in the agreement. This document may not, in whole or in part, be copied, photocopied, reproduced, translated, or reduced to any electronic medium or machine readable form without prior consent, in writing, from BEA Systems, Inc. Use, duplication or disclosure by the U.S. Government is subject to restrictions set forth in the BEA Systems License Agreement and in subparagraph (c)(1) of the Commercial Computer Software-Restricted Rights Clause at FAR 52.227-19; subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, subparagraph (d) of the Commercial Computer Software--Licensing clause at NASA FAR supplement 16-52.227-86; or their equivalent. Information in this document is subject to change without notice and does not represent a commitment on the part of BEA Systems. THE SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, BEA Systems DOES NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE, OR THE RESULTS OF THE USE, OF THE SOFTWARE OR WRITTEN MATERIAL IN TERMS OF CORRECTNESS, ACCURACY, RELIABILITY, OR OTHERWISE.

Trademarks or Service Marks


BEA, Jolt, Tuxedo, and WebLogic are registered trademarks of BEA Systems, Inc. BEA Builder, BEA Campaign Manager for WebLogic, BEA eLink, BEA Liquid Data for WebLogic, BEA Manager, BEA WebLogic Commerce Server, BEA WebLogic Enterprise, BEA WebLogic Enterprise Platform, BEA WebLogic Express, BEA WebLogic Integration, BEA WebLogic Personalization Server, BEA WebLogic Platform, BEA WebLogic Portal, BEA WebLogic Server, BEA WebLogic Workshop and How Business Becomes E-Business are trademarks of BEA Systems, Inc. All other trademarks are the property of their respective companies.

Contents

1. Introduction and Roadmap


Document Scope and Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Guide to this Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Related Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 WLST Samples and Tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

2. Using the WebLogic Server Scripting Tool


What is the WebLogic Server Scripting Tool? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 What Does it Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 How Does it Work?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Basic Steps for Using WLST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Setting up Your Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Invoking the WLST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Using Interactive Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Using Script Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 Navigating and Interrogating MBeans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Browsing the Runtime Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

Using the WebLogic Server Scripting Tool

iii

WLST Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 WLST Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 STOREUSERCONFIG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 DISCONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 Browse Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 CONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 ADMINCONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 CUSTOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 RUNTIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 Edit Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
iv Using the WebLogic Server Scripting Tool

GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 INVOKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 CREATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 SAVEDOMAIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Deployment Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 DEPLOY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 UNDEPLOY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 REDEPLOY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
Using the WebLogic Server Scripting Tool v

Life Cycle Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 START . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 SUSPEND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 RESUME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 STARTSERVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 Information Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 PROMPT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42 PWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43 LS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44 STATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
vi Using the WebLogic Server Scripting Tool

HELP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46 DUMPVARIABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47 DUMPSTACK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47 LOADPROPERTIES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 MAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48 STARTRECORDING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 STOPRECORDING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49 Script Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50 CONFIGTOSCRIPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50 Running Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51 EXECFILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52
Using the WebLogic Server Scripting Tool vii

viii

Using the WebLogic Server Scripting Tool

CHAPTER

Introduction and Roadmap

This section describes the contents and organization of this guideUsing the WebLogic Server Scripting Tool. Document Scope and Audience on page 1-1 Guide to this Document on page 1-1 Related Documentation on page 1-2 WLST Samples and Tutorials on page 1-2

Document Scope and Audience


This document is written for WebLogic Server administrators and operators deploying J2EE applications using the Java 2 Platform, Enterprise Edition (J2EE) from Sun Microsystems. It is assumed that readers are familiar with Web technologies and the operating system and platform where WebLogic Server is installed.

Guide to this Document


This document introduces and describes using the BEA WebLogic Server Scripting Tool (WLST) online to interact with and configure WebLogic Server versions 8.1 and 7.0. This document covers the following topics: This chapter, Introduction and Roadmap, introduces the organization of this guide.

Using the WebLogic Server Scripting Tool

1-1

I n tr o d uct i o n a nd R o a dm a p

Chapter 2, Using the WebLogic Server Scripting Tool, describes the basic steps for invoking the WLST, its modes of operation, and contains the scripting language reference.

Related Documentation
For information on using WLST offline, see Using the WebLogic Server Scripting Tool for Offline Configuration, delivered with the WLST offline configuration kit that is available at http://dev2dev.bea.com/codelibrary/code/wlst_offline.jsp. Creating and configuring WebLogic Servers and Domains Managing a WebLogic Server Domain Administration Console Online Help

WLST Samples and Tutorials


TBD

1-2

Using the WebLogic Server Scripting Tool

CHAPTER

Using the WebLogic Server Scripting Tool

The WebLogic Server Scripting Tool (WLST) is a command-line scripting interface that you use to interact with and configure WebLogic Server. Using WLST, WebLogic Server administrators and operators can perform administrative tasks and initiate WebLogic Server configuration changes interactively or by using an executable script. Currently, WebLogic Server supports the following command-line utilities that you use to interact with and configure a WebLogic Server instance: the weblogic.Admin utility and wlconfig Ant task tool for making WebLogic Server configuration changes and interrogating MBeans, and the weblogic.Deployer utility for deploying applications. WLST functionality includes the capabilities of these command-line tools. Additionally, each command that you enter for a WebLogic Server instance uses the same connection to the server that has already been established, eliminating the need for user re-authentication and a separate JVM to execute the command. The following sections describe using the WebLogic Server Scripting Tool: What is the WebLogic Server Scripting Tool? on page 2-2 Basic Steps for Using WLST on page 2-4 Modes of Operation on page 2-5 Navigating and Interrogating MBeans on page 2-7 WLST Variables on page 2-18 WLST Commands on page 2-19

Using the WebLogic Server Scripting Tool

2-1

Usin g t h e W ebL ogi c S erver Scripting T ool

Script Generation on page 2-50 Running Scripts on page 2-51 For more information, see: Using the WebLogic Server Scripting Tool for Offline Configuration available at http://dev2dev.bea.com/codelibrary/code/wlst_offline.jsp. Describes using WLST offline to create a new domain or update an existing domain without connecting to a running WebLogic Serversupporting the same functionality as the Configuration Wizard. Using Command-Line Utilities to Configure a WebLogic Server Domain in WebLogic Server Command Reference. Provides extended examples of using weblogic.Admin commands to configure a WebLogic Server domain. Using Ant Tasks to Configure a WebLogic Server Domain in WebLogic Server Command Reference. Describes using WebLogic Ant tasks for starting and stopping WebLogic Server instances and configuring WebLogic Server domains. Deployment Tools Reference in Deploying WebLogic Server Applications. Describes how to deploy J2EE modules on a WebLogic Server instance using the weblogic.Deployer command-line utility.

What is the WebLogic Server Scripting Tool?


The WebLogic Server Scripting Tool (WLST) is a command-line scripting interface for WebLogic Server. The WLST scripting environment is based on the Java scripting interpreter, Jython. WLST lets you make use of the provided WebLogic Server scripting functions as well as common features of interpreted languages; these include local variables, conditional variables, and flow control statements. WebLogic Server developers and administrators can extend the WebLogic Server scripting language to suit their environmental needs by following the Jython language syntax. For more information, see http://www.jython.org.

What Does it Do?


WLST provides simplified access to Managed Beans (MBeans), WebLogic Server Java objects that you manage through JMX. While the weblogic.Admin utility and the WLST provide an interface for interacting with MBeans, the manner in which you retrieve MBeans is different.

2-2

Using the WebLogic Server Scripting Tool

How Does it Work?

The MBean-related commands that the weblogic.Admin utility provides require you to determine the object name of the MBean with which you want to interact. While the object name is generated based on documented conventions, it can be difficult to accurately determine the object names of child MBeans several layers within a hierarchy. WLST offers a different style of retrieving MBeans: instead of providing object names, you navigate a hierarchy of MBeans in a similar fashion to navigating a hierarchy of files in a file system. In the WLST file system, Administration, Local Configuration, Custom, and Runtime MBean hierarchies correspond to drives; MBean types and MBeans instances are directories; MBean attributes and operations are files. WLST navigates MBeans using commands such as CD, LS, and PWD in a similar way that you would navigate a file system in a UNIX or Windows command shell. The LS command displays all the MBean types, instances, attributes, or operations of the MBean to which you navigate, depending on an optional command argument that you supply. (See LS on page 2-43.) Using the CD command, you can navigate to any MBean contained in the hierarchy. After navigating to an MBean instance, you interact with the MBean using WLST commands. For the complete list of WLST commands, see WLST Commands on page 2-19. The WLST lets you perform the following tasks: Navigate and interrogate all the MBeans in a domain, including Administration, Local Configuration, Runtime, and any Custom MBeans registered in the server. Navigate, interrogate, and edit Administration MBeans on a WebLogic Administration Server. Navigate and interrogate Local Configuration MBeans on a WebLogic Managed Server. For more information on WebLogic Server MBeans, see WebLogic Server Managed Resources and MBeans in Programming WebLogic Management Services with JMX. For a complete list of all WebLogic Server MBean interface classes, see the WebLogic Server Management APIs.

How Does it Work?


The WLST is a command-line interpreter that interprets commands either interactively, supplied one-at-a-time from a command prompt, or in batches, supplied in a file (script). You can use the

Using the WebLogic Server Scripting Tool

2-3

Usin g t h e W ebL ogi c S erver Scripting T ool

scripting tool online (connected to a running server) and offline (not connected to a running server). When connected to an Administration Server instance, the scripting tool lets you navigate, interrogate, and supply configuration data to the server. When connected to a Managed Server instance, WLST functionality is limited to browsing the MBean hierarchy; BEA Systems recommends that you do not edit MBeans on a Managed Server. Managed Servers retrieve their configuration data from the Administration Server. While you cannot use WLST to change the values of MBeans on Managed Servers, it is possible to use the weblogic.Admin utility and the Management APIs to do so. BEA Systems recommends that you change only the values of Administration MBeans on the Administration Server. Changing the values of MBeans on Managed Servers can lead to an inconsistent domain configuration. Offline, WLST provides access only to persisted configuration information. You can create new configuration information, and retrieve and change existing configuration values that are stored either in the domain config.xml file or in a domain template JAR that the Configuration Template Builder creates. Note: Using WLST offline is not implemented in this release. For information on using WLST offline, see Using the WebLogic Server Scripting Tool for Offline Configuration, delivered with the WLST offline configuration kit that is available at http://dev2dev.bea.com/codelibrary/code/wlst_offline.jsp.

Basic Steps for Using WLST


The following sections describe configuring your environment and invoking WLST.

Setting up Your Environment


To set up your environment for WLST: 1. Install and configure the WebLogic Server software, as described in the WebLogic Server Installation Guide. See {DOCROOT}/install/index.html. 2. Add WebLogic Server classes to the CLASSPATH environment variable and WL_HOME\server\bin to the PATH environment variable, where WL_HOME refers to the top-level installation directory for WebLogic Platform. You can use a WL_HOME\server\bin\setWLSenv script to set both variables. See Setting the Classpath in WebLogic Server Command Reference.

2-4

Using the WebLogic Server Scripting Tool

Inv oki ng the WLST

3. Download and add wlst.jar to the CLASSPATH environment variable. 4. Download and add jython.jar to the CLASSPATH environment variable. The Jython JAR file is located at http://www.jython.org/download.html.

Invoking the WLST


To invoke the WLST: 1. At a command prompt, enter the following command:
java weblogic.WLST

Note: Command names and arguments are case sensitive. The Jython package manager processes the JAR files in your classpath. A welcome message and the WLST prompt appears:
wls:/(offline)>

2. To connect to a running WebLogic Server instance, use the CONNECT command. (See CONNECT on page 2-20.)
wls:/(offline)> connect('weblogic','weblogic') Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ...

Modes of Operation
The WLST operates in two modes: interactive and script. Interactive mode, in which you enter a command and view the response at a command-line prompt, is useful for learning the tool, prototyping command syntax, and verifying configuration options before building a script. Interactive mode is particularly useful for getting immediate feedback after making a critical configuration change. Script mode lets you supply WLST commands in a file that the tool invokes without requiring user interaction, much like a shell script. In script mode, you can apply the same configuration settings, iteratively, across multiple nodes of a topology. Moreover, in script mode you can take advantage of scripting language features, such as loops, flow control constructs, conditional statements, and variable evaluations that are limited in interactive mode.

Using Interactive Mode


The interactive scripting shell lets you enter WLST commands and view the response at a command-line prompt. The WLST scripting shell maintains a persistent connection with an instance of WebLogic Server. Since a persistent connection is maintained throughout the user
Using the WebLogic Server Scripting Tool 2-5

Usin g t h e W ebL ogi c S erver Scripting T ool

session, you can capture multiple steps that are performed against the server. In addition, each command that you enter for a WebLogic Server instance, uses the same connection that has already been established, eliminating the need for user re-authentication and a separate JVM to execute the command.

Using Script Mode


Script mode invokes a sequence of commands without requiring your input, much like a shell script. Using WLST in script mode, you can do the following: Automate WebLogic Server configuration and application deployment. Schedule scripts to run against the server at various times. Automate repetitive tasks and complex procedures. Configure an application in a hands-free data center. The following script connects to an Administration Server instance, creates ten Managed Servers and two clusters, and assigns the servers to a cluster:
from java.util import * from javax.management import * import javax.management.Attribute print 'starting the script .... ' connect('weblogic','weblogic','t3://localhost:7001') clusters = "cluster1","cluster2" ms1 = {'managed1':7701,'managed2':7702,'managed3':7703, 'managed4':7704, 'managed5':7705} ms2 = {'managed6':7706,'managed7':7707,'managed8':7708, 'managed9':7709, 'managed10':7710} clustHM = HashMap() serverName = mbs.getServerName() cd('Servers') cd(serverName) for c in clusters: print 'creating cluster '+c clu = create(c,'Cluster') clustHM.put(c,clu)

2-6

Using the WebLogic Server Scripting Tool

Navi ga ti ng an d Int er r oga t ing M Bean s

cd('..\..') clus1 = clustHM.get(clusters[0]) clus2 = clustHM.get(clusters[1]) for m, lp in ms1.items(): managedServer = create(m,'Server') print 'creating managed server '+m managedServer.setListenPort(lp) managedServer.setCluster(clus1) for m1, lp1 in ms2.items(): managedServer = create(m1,'Server') print 'creating managed server '+m1 managedServer.setListenPort(lp1 managedServer.setCluster(clus2) disconnect() print 'End of script ...' exit()

For more information on WLST scripts, see Running Scripts on page 2-51.

Navigating and Interrogating MBeans


MBeans in a WebLogic Server domain are arranged in a hierarchical JMX namespace that you use when looking up MBeans. WLST provides simplified access to WebLogic Server MBeans by using a model that is similar to the directories in a file system: the root directory is DomainMBean in the configuration hierarchy and DomainRuntimeMBean in the runtime hierarchy, the MBean type is a subdirectory under the root directory, the name of the MBean (the MBean instance) is a subdirectory under the MBean type directory, and MBean attributes and operations are nodes (like files) under the MBean directory. Each MBean instance is a subdirectory of an MBean type. In most cases, there can be multiple instances of a type. You navigate MBeans using WLST commands, such as CD, LS, and PWD, in a similar way that you would navigate a file system using a UNIX or Windows command shell. After navigating to an MBean instance, you interact with the MBean using WLST commands. When WLST first connects to an instance of WebLogic Server through the interactive scripting shell, the variable, CMO (Current Management Object), is initialized to the root of all configuration management objects, DomainMBean. When you navigate to an MBean type, the value of the CMO reflects the parent MBean. When you navigate to an MBean instance, WLST changes the value of the CMO to be the current MBean instance, as shown in the following example.
Using the WebLogic Server Scripting Tool 2-7

Usin g t h e W ebL ogi c S e rver Scripting T ool

C:\> java weblogic.WLST Welcome to Weblogic Server Administration Scripting Shell Type help() for help on available commands wls:/(offline)> connect('weblogic','weblogic') Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'. wls:/mydomain/config> cmo [Caching Stub]Proxy for mydomain:Name=mydomain,Type=Domain wls:/mydomain/config> cd('Servers') wls:/mydomain/config/Servers> cmo [Caching Stub]Proxy for mydomain:Name=mydomain,Type=Domain wls:/mydomain/config/Servers> cd('myserver') wls:/mydomain/config/Servers/myserver> cmo [Caching Stub]Proxy for mydomain:Name=myserver,Type=Server

After navigating to an MBean instance, WLST changes the value of the CMO from DomainMBean to ServerMBean.

Example
The following example instructs WLST to connect to an Administration Server instance, navigate, and display Administration MBeans in DomainMBean. If no argument is specified, the LS command lists all the child MBeans. If there are no child MBeans, the command displays the MBean attributes:
C:\> java weblogic.WLST Welcome to Weblogic Server Administration Scripting Shell Type help() for help on available commands wls:/(offline) > connect('weblogic','weblogic') Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'. wls:/mydomain/config> ls() drwApplicationManager drwdrwdrwApplications BasicRealms BridgeDestination

2-8

Using the WebLogic Server Scripting Tool

Navi ga ti ng an d Int er r oga t ing M Bean s

drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrw-

BridgeDestinationCommon CachingRealms Clusters ConversationService DomainLogFilter EmbeddedLDAP FileRealm FileT3s ForeignJMSServer HTTPProxy JDBCConnectionPools JDBCDataSourceFactories JDBCDataSources JDBCMultiPools JDBCTxDataSources JMSConnectionFactory JMSDestinations JMSDistributedQueues JMSDistributedTopics JMSFileStores JMSJDBCStores JMSQueues JMSServers JMSSessionPool JMSStores JMSTemplates JMSTopics JMSVirtualDestination JTA JoltConnectionPool Kernel Log Machines MailSession MessagingBridges MigratableRMIServices NetworkChannels PasswordPolicies

Using the WebLogic Server Scripting Tool

2-9

Usin g t h e W ebL ogi c S erver Scripting T ool

drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrw-

Realms ReliableDeliveryPolicy SNMPAgent Security SecurityConfiguration Servers ShutdownClasses StartupClasses UnixMachine VirtualHosts WLECConnectionPool WSReliableDeliveryPolicies WTCServers XMLEntityCache XMLEntitySpecRegistryEntry XMLParserSelectRegistryEntry

drwXMLRegistries wls:/mydomain/config>

The first d in the output information designates an MBean with which you can use the CD command (analogous to a directory in a file system). Table 2-8 describes the LS command output information.
wls:/mydomain/config> cd('Servers') wls:/mydomain/config/Servers> ls() drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwmanaged1 managed10 managed2 managed3 managed4 managed5 managed6 managed7 managed8 managed9 managedServer

drwmyserver wls:/mydomain/config/Servers> cd('myserver') wls:/mydomain/config/Servers/myserver> ls()

2-10

Using the WebLogic Server Scripting Tool

Navi ga ti ng an d Int er r oga t ing M Bean s

drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrw-

COM ExecutiveQueue IIOP JTAMigratableTarget JTARecoveryService KernelDebug Log NetworkAccessPoint ReliableDeliveryPolicy SSL ServerDebug ServerStart WebServer

wls:/mydomain/config/Servers/myserver> cd('Log') wls:/mydomain/config/Servers/myserver/Log> ls() drwmyserver wls:/mydomain/config/Servers/myserver/Log> cd ('myserver') wls:/mydomain/config/Servers/myserver/Log/myserver> ls() -r--rw-rw-rw-rw-rw-rw-rw-rw-rw-r--rw-rw-r-CachingDisabled FileCount FileMinSize FileName FileTimeSpan Name Notes NumberOfFilesLimited ObjectName Parent Registered RotationTime RotationType Type true 7 500 .\myserver\myserver.log 24 myserver null false mydomain:Name=myserver,Server=myserver,Type=Log mydomain:Name=myserver,Type=Server false 00:00 bySize Log

After navigating to an MBean instance, you can interrogate that MBean for attributes. To navigate back to a parent MBean, enter the cd(..) command, as shown in the following example.
wls:/mydomain/config/Servers/myserver/Log/myserver> cmo [Caching Stub]Proxy for mydomain:Name=myserver,Server=myserver,Type=Log

Using the WebLogic Server Scripting Tool

2-11

Usin g t h e W ebL ogi c S e rver Scripting T ool

wls:/mydomain/config/Servers/myserver/Log/myserver> cd('..') wls:/mydomain/config/Servers/myserver/Log> wls:/mydomain/config/Servers/myserver/Log> cmo [Caching Stub]Proxy for mydomain:Name=myserver,Type=Server

After navigating back to the parent MBean type, WLST changes the CMO from LogMBean to ServerMBean.

Example
The following example instructs WLST to connect to a Managed Server instance, navigate, and display Local Configuration MBeans, designated by the Config suffix in the MBean name:
C:\> java weblogic.WLST wls:/(offline)> connect(weblogic,weblogic,t3://localhost:7701) Connecting to weblogic server instance running at t3://localhost:7701 as username weblogic ... Successfully connected to managed Server 'managed1' that belongs to domain 'mydomain'. This server belongs to cluster 'cluster1'. wls:/mydomain/config> ls() dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-ApplicationManagerConfig ApplicationsConfig BasicRealmsConfig BridgeDestinationCommonConfig BridgeDestinationConfig CachingRealmsConfig ClustersConfig ConversationServiceConfig DomainLogFilterConfig EmbeddedLDAPConfig FileRealmConfig FileT3sConfig ForeignJMSServerConfig HTTPProxyConfig JDBCConnectionPoolsConfig JDBCDataSourceFactoriesConfig JDBCDataSourcesConfig JDBCMultiPoolsConfig JDBCTxDataSourcesConfig JMSConnectionFactoryConfig

2-12

Using the WebLogic Server Scripting Tool

Navi ga ti ng an d Int er r oga t ing M Bean s

dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr-dr--

JMSDestinationsConfig JMSDistributedQueuesConfig JMSDistributedTopicsConfig JMSFileStoresConfig JMSJDBCStoresConfig JMSQueuesConfig JMSServersConfig JMSSessionPoolConfig JMSStoresConfig JMSTemplatesConfig JMSTopicsConfig JMSVirtualDestinationConfig JTAConfig JoltConnectionPoolConfig KernelConfig LogConfig MachinesConfig MailSessionConfig MessagingBridgesConfig MigratableRMIServicesConfig NetworkChannelsConfig PasswordPoliciesConfig RealmsConfig ReliableDeliveryPolicyConfig SNMPAgentConfig SecurityConfig SecurityConfigurationConfig ServersConfig ShutdownClassesConfig StartupClassesConfig UnixMachineConfig VirtualHostsConfig WLECConnectionPoolConfig WSReliableDeliveryPoliciesConfig WTCServersConfig XMLEntityCacheConfig XMLEntitySpecRegistryEntryConfig XMLParserSelectRegistryEntryConfig

Using the WebLogic Server Scripting Tool

2-13

Usin g t h e W ebL ogi c S erver Scripting T ool

dr--

XMLRegistriesConfig

wls:/mydomain/config> wls:/mydomain/config> cd('ClustersConfig') wls:/mydomain/config/ClustersConfig> ls() dr-cluster1 wls:/mydomain/config/ClustersConfig> cd('cluster1') wls:/mydomain/config/ClustersConfig/cluster1> ls() -r--r--r--r--r--r--r--r--r--r--r--r--r--r--r-CachingDisabled ClientCertProxyEnabled ClusterAddress DefaultLoadAlgorithm FrontendHTTPPort FrontendHTTPSPort FrontendHost MulticastAddress MulticastBufferSize MulticastPort MulticastSendDelay MulticastTTL Name Notes ObjectName true false null round-robin 0 0 null 237.0.0.1 64 7001 3 1 cluster1 null

mydomain:Location=managed1,Name=cluster1,Type=ClusterConfig -r-Parent mydomain:Location=managed1,Name=mydomain,Type=DomainConfig -r--r-Registered Servers false

mydomain:Location=managed1,Name=managed2,Type=ServerConfig|mydomain:Locati on=managed1,Name=managed1,Type=ServerConfig|mydomain:Location=managed1,Nam e=managed4,Type=ServerConfig|mydomain:Location=managed1,Name=managed5,Type =ServerConfig|mydomain:Location=managed1,Name=managed3,Type=ServerConfig -r-Type ClusterConfig false -r-WeblogicPluginEnabled wls:/mydomain/config/ClustersConfig/cluster1>

In the LS command output information, r indicates a readable property and w indicates a writeable property. The example shows that Local Configuration MBeans on a Managed Server are read-only; you cannot edit them using WLST.

2-14

Using the WebLogic Server Scripting Tool

Bro wsing the Runtime Informatio n

Browsing the Runtime Information


Similar to the configuration information, Runtime MBeans on WebLogic Server are arranged in a hierarchical JMX namespace. You access the Runtime MBean hierarchy by entering the RUNTIME command which places WLST at the root of all the runtime management objects, DomainRuntimeMBean, and sets the CMO variable to DomainRuntimeMBean. When connected to a Managed Server, the root of Runtime MBeans is ServerRuntimeMBean. Using the CD command, WLST can navigate to any of the runtime child MBeans. The navigation model for Runtime MBeans is similar to the navigation model for Local Configuration MBeans. However, Runtime MBeans exist only on the same server instance as their underlying managed resources and they are un-editable.

Example
The following example instructs WLST to connect to an Administration Server instance, navigate, and display Runtime MBeans in DomainRuntimeMBean:
wls:/(offline) > connect('weblogic','weblogic') Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'. wls:/mydomain/config> runtime() wls:/mydomain/runtime> ls() drwDeployerRuntime drwServerRuntimes wls:/mydomain/runtime> cd('ServerRuntimes') wls:/mydomain/runtime/ServerRuntimes> ls() drwmyserver wls:/mydomain/runtime/ServerRuntimes> cd('myserver') wls:/mydomain/runtime/ServerRuntimes/myserver> ls() drwdrwdrwdrwdrwdrwdrwdrwApplicationRuntimes ClusterRuntime ConnectorServiceRuntime DomainLogHandlerRuntime ExecuteQueueRuntimes JDBCConnectionPoolRuntime JMSRuntime JTARecoveryRuntime

Using the WebLogic Server Scripting Tool

2-15

Usin g t h e W ebL ogi c S e rver Scripting T ool

drwdrwdrwdrwdrwdrwdrwdrw-

JVMRuntime LogBroadcasterRuntime MigratableServiceCoordinatorRuntime ServerLifeCycleRuntime TimeServiceRuntime TransactionResourceRuntime WLECConnectionServiceRuntime WebServerRuntime

wls:/mydomain/runtime/ServerRuntimes/myserver> wls:/mydomain/runtime/ServerRuntimes/myserver> cd('JVMRuntime') wls:/mydomain/runtime/ServerRuntimes/myserver/JVMRuntime> ls() drwmyserver wls:/mydomain/runtime/ServerRuntimes/myserver/JVMRuntime> cd('myserver') wls:/mydomain/runtime/ServerRuntimes/myserver/JVMRuntime/myserver> ls() -r--r--r--r--r--rw-r--r--rwCachingDisabled HeapFreeCurrent HeapSizeCurrent JavaVendor JavaVersion Name OSName OSVersion ObjectName true 18140472 33357824 Sun Microsystems Inc. 1.4.1_05 myserver Windows 2000 5.0

mydomain:Location=myserver,Name=myserver,ServerRuntime=myserver, Type=JVMRuntime -rw-r--r-Parent Type mydomain:Location=myserver,Name=myserver,Type=ServerRuntime false JVMRuntime Registered

wls:/mydomain/runtime/ServerRuntimes/myserver/JVMRuntime/myserver>

The example shows that the Runtime MBean attributes are read-only; you cannot edit them.

Example
The following example instructs WLST to navigate and display Runtime MBeans on a Managed Server instance:
wls:/(offline)> connect(weblogic,weblogic,t3://localhost:7701) Connecting to weblogic server instance running at t3://localhost:7701 as username weblogic ...

2-16

Using the WebLogic Server Scripting Tool

Bro wsing the Runtime Informatio n

Successfully connected to managed Server 'managed1' that belongs to domain 'mydomain'. This server belongs to cluster 'cluster1'. wls:/mydomain/config> runtime() wls:/mydomain/runtime/ServerRuntime/managed1> ls() drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwApplicationRuntimes ClusterRuntime ConnectorServiceRuntime DomainLogHandlerRuntime ExecuteQueueRuntimes JDBCConnectionPoolRuntime JMSRuntime JTARecoveryRuntime JVMRuntime LogBroadcasterRuntime MigratableServiceCoordinatorRuntime ServerLifeCycleRuntime TimeServiceRuntime TransactionResourceRuntime WLECConnectionServiceRuntime

drwWebServerRuntime wls:/mydomain/runtime/ServerRuntime/managed1> cd('ClusterRuntime') wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime> ls() dr-managed1 wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime> cd('managed1') wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime/managed1> ls() -r--r--r--r--r--r--r--r-AliveServerCount CachingDisabled ForeignFragmentsDroppedCount FragmentsReceivedCount FragmentsSentCount MulticastMessagesLostCount Name ObjectName 1 true 461 833 372 0 cluster1

mydomain:Location=managed1,Name=managed1,ServerRuntime=managed1, Type=ClusterRuntime -r-Parent mydomain:Location=managed1,Name=managed1,Type=ServerRuntime

Using the WebLogic Server Scripting Tool

2-17

Usin g t h e W ebL ogi c S erver Scripting T ool

-r--r--r--r--r--r--

PrimaryCount Registered ResendRequestsCount SecondaryDistributionNames ServerNames Type

0 false 0 [Ljava.lang.String;@a159bb [Ljava.lang.String;@18849be ClusterRuntime

wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime/managed1>

In the example, entering the RUNTIME command in a Managed Server instance, places WLST at ServerRuntimeMBean; there is no domain Runtime MBean in a Managed Server. To navigate to a Local Configuration MBean from the runtime hierarchy, enter the CONFIG command. This places WLST at the Local Configuration MBean to which you last navigated before entering the RUNTIME command. The following example instructs WLST to navigate from the Runtime MBean hierarchy to the Local Configuration MBean hierarchy and back:
wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime/managed1> config() wls:/mydomain/config> cd(ServersConfig/managed1) wls:/mydomain/config/ServersConfig/managed1> runtime() wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime/managed1>

Entering the CONFIG command from the Runtime MBean hierarchy again, places WLST at the Local Configuration MBean to which you last navigated.
wls:/mydomain/runtime/ServerRuntime/managed1/ClusterRuntime/managed1> config() wls:/mydomain/config/ServersConfig/managed1>

WLST Variables
Table 2-1 describes WLST variables and their common usage. All variables are initialized to default values at the start of a user session and are changed according to the user interaction with WLST.

2-18

Using the WebLogic Server Scripting Tool

WLST Commands

Table 2-1 WLST Variables Variable


cmo

Definition
Current Management Object. Set to the MBean instance to which WLST navigates. You use this variable to perform any GET, SET, or INVOKE method on the current MBean instance. By default, this variable is initialized to the root of all configuration management objects, DomainMBean. Set to True when WLST is connected to a running server. Stores the name of the domain to which WLST is connected. Stores the username for WLST connection. Set to True when WLST is connected to a WebLogic Administration Server instance. Stores the name of the server to which WLST is connected. Stores the current version of the running server to which WLST is connected. Set to True when the STARTRECORDING command is entered. Default = False. Terminates script execution when WLST encounters an exception. Default = True. This variable is not applicable when running WLST in interactive mode.

connected domainName username isAdminServer

serverName version recording exitonerror

WLST Commands
WLST commands (primitives) are executable functions that are extensions to the Jython language and are available in WLST at startup. You extend or modify WLST primitives by following the Jython language syntax. Most of the primitives defined in WLST are convenience commands; you can attain the equivalent functionality by directly invoking methods on the underlying Management APIs. For a complete list of all WebLogic Server MBean interface classes, see the WebLogic Server Management APIs. The following sections describe WLST commands and how to use them. These commands are available when using WLST in interactive and script mode. Most commands are available when using WLST online and offline. Exceptions are noted. Note: Using WLST offline is not implemented in this release.

Using the WebLogic Server Scripting Tool

2-19

Usin g t h e W ebL ogi c S erver Scripting T ool

WLST commands are divided into 6 categories, Control, Browse, Edit, Deploy, Life Cycle, and Information. Each major section contains an overview of the commands in the category. Subsequent sections describe command syntax and arguments, and provide an example for each command. Note: Command names and arguments are case sensitive.

Control Commands
Table 2-2 describes commands for connecting WLST to a WebLogic Server instance. Table 2-2 WLST Online Control Commands Command
CONNECT

Description
Connect WLST to a WebLogic Server instance. See CONNECT on page 2-20.

STOREUSERCONFIG

Create a user-configuration file and an associated key file. See STOREUSERCONFIG on page 2-22.

DISCONNECT

Disconnect WLST from a WebLogic Server instance. See DISCONNECT on page 2-23.

EXIT

Disconnect WLST from the interactive session and close the scripting shell. See EXIT on page 2-23.

CONNECT
Connects WLST to a WebLogic Server instance. You specify the username, password, and the URL of the server to which you want to connect. If you do not specify the URL, WLST uses the default URL, t3://localhost:7001. Instead of supplying the username and password on the command-line, you can use an encrypted password that is stored locally by specifying the locations of the user-configuration and key files as arguments to the CONNECT command. For more information, see Specifying User Credentials in WebLogic Server Command Reference. After successfully connecting to a WebLogic Server instance, all the local variables are initialized.
2-20 Using the WebLogic Server Scripting Tool

C O NN E C T

Note: If you connect to a Managed Server, WLST functionality is limited to browsing the MBean hierarchy; BEA Systems recommends that you do not edit the Local Configuration MBeans on a Managed Server. Managed Servers retrieve their configuration data from the Administration Server.

Syntax
connect(username,password,[url]) connect(userConfigFile,userKeyFile,[url])

Argument
username password [url] [protocol://]listenaddress:listen-port userConfigFile

Definition
Username for connecting WLST to the server. Password for connecting WLST to the server. Optional. Listen address and listen port of the server instance. If not specified, WLST uses the default URL, t3://localhost:7001.

Name and location of a user-configuration file which contains an encrypted username and password. When you create a user-configuration file, the STOREUSERCONFIG command uses a key file to encrypt the username and password. Only the key file that encrypts a user-configuration file can decrypt the username and password. (See STOREUSERCONFIG on page 2-22.)

userKeyFile

Name and location of the key file that is associated with the user-configuration file you specify.

Examples
The following command connects WLST to a WebLogic Server instance:
wls:/(offline) > connect('system','weblogic') Connecting to weblogic server instnace running at t3://localhost:7001 as username system... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'. wls:/mydomain/config>

The following command connects WLST to a WebLogic Server instance at the specified URL:
Using the WebLogic Server Scripting Tool 2-21

Usin g t h e W ebL ogi c S e rver Scripting T ool

wls:/(offline)> username = 'weblogic' wls:/(offline)> password = 'weblogic' wls:/(offline)> connect(username,password,'t3://localhost:7001') Connecting as 'weblogic' to WebLogic Server instance running at 't3://localhost:7001' .... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'. wls:/mydomain/config>

The following command connects WLST to a WebLogic Server instance using a user-configuration and key file to provide user credentials:
wls:/(offline)> connect(userConfigFile=c:/myfiles/myUserConfig.secure, userKeyFile=c:/myfiles/mykeys/myKey.secure) Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ... Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'.

STOREUSERCONFIG
Creates a user-configuration file and an associated key file. The user-configuration file contains an encrypted username and password. The key file contains a secret key that is used to encrypt and decrypt the username and password. Only the key file that originally encrypted the username and password can decrypt the values. If you lose the key file, you must create a new user-configuration and key file pair.

Syntax
storeUserConfig(userConfigFile,userKeyFile)

Argument
userConfigFile

Definition
Specifies a file pathname at which the STOREUSERCONFIG command creates a user-configuration file. The pathname can be absolute or relative to the directory from which you enter the command. Specifies a file pathname at which the STOREUSERCONFIG command creates a key file that is associated with the user-configuration file you specify. The pathname can be absolute or relative to the directory from which you enter the command.

userKeyFile

2-22

Using the WebLogic Server Scripting Tool

D I S C O NN E C T

Example
The following command creates and stores a user-configuration file and key file in the specified locations:
wls:/mydomain/config> storeUserConfig(c:/myFiles/myuserconfigfile.secure, c:/myFiles/myuserkeyfile.secure) The username and password that were used for this current connection are stored in c:/myFiles/myuserconfigfile.secure and c:/myFiles/myuserkeyfile.secure wls:/mydomain/config>

DISCONNECT
Disconnects WLST from a WebLogic Server instance. The DISCONNECT command does not cause WLST to exit the interactive scripting shell; it closes the current WebLogic Server instance connection and resets all the variables while keeping the interactive shell alive. Entering the CONNECT command again connects WLST to another WebLogic Server instance.

Syntax
disconnect()

Example
The following command instructs WLST to disconnect from a running server:
wls:/mydomain/config> disconnect() Disconnected from weblogic server: myserver wls:/(offline)>

EXIT
Disconnects WLST from the user session and closes the scripting shell.

Syntax
exit()

Using the WebLogic Server Scripting Tool

2-23

Usin g t h e W ebL ogi c S erver Scripting T ool

Example
The following example instructs WLST to disconnect from the user session and close the scripting shell:
wls:/mydomain/config> exit() Exiting WLS scripting shell c:\>

Browse Commands
Table 2-3 describes navigation commands WLST uses to traverse the MBean hierarchies. All the browse commands apply to using WLST online and offline. Table 2-3 Browse Commands Command
CD

Description
Navigate the MBean namespace. See CD on page 2-24.

CONFIG

Navigate to the root of Administration MBeans, when connected to an Administration Server instance, or to the root of Local Configuration MBeans, when connected to a Managed Server instance. See CONFIG on page 2-25.

ADMINCONFIG

Navigate to the root of Local Configuration MBeans on an Administration Server instance. See ADMINCONFIG on page 2-26.

CUSTOM

Navigate to the root of Custom MBeans that are registered in the server. See CUSTOM on page 2-27.

RUNTIME

Navigate to the root of Runtime MBeans. See RUNTIME on page 2-27.

CD
The CD command navigates the hierarchy of MBeans using a model that is similar to navigating a file system in a Windows or UNIX command shell. Using the CD command, you navigate to MBeans in the current MBean hierarchy and to any child MBean and MBean instance.

2-24

Using the WebLogic Server Scripting Tool

CONFIG

To navigate back to a parent MBean, enter the cd(..) command. To get back to the root MBean after navigating to an MBean that is deep in the hierarchy, enter the cd(/) command. For more information, see Navigating and Interrogating MBeans on page 2-7.

Syntax
cd(MBeanPath)

Argument
MBeanPath

Definition
Path to MBean in the namespace.

Example
The following example instructs WLST to navigate from DomainMBean to LogMBean and back:
wls:/mydomain/config> cd('Servers') wls:/mydomain/config/Servers> cd('myserver) wls:/mydomain/config/Servers/myserver> cd('Log/myserver') wls:/mydomain/config/Servers/myserver/Log/myserver> cd('../../../..') wls:/mydomain/config>

CONFIG
Navigates to the root of all configuration objects, DomainMBean, and sets the CMO variable to DomainMBean. When connected to an Administration Server instance, the CONFIG command places WLST at the root of the Administration MBeans. When connected to a Managed Server instance, the CONFIG command places WLST at the root of the Local Configuration MBeans. Entering the CONFIG command to navigate back to a Administration or Local Configuration MBean from the runtime hierarchy, places WLST at the Administration or Local Configuration MBean to which you last navigated before you entered the RUNTIME command. For more information, see Browsing the Runtime Information on page 2-15.

Syntax
config()

Using the WebLogic Server Scripting Tool

2-25

Usin g t h e W ebL ogi c S erver Scripting T ool

Example
The following example instructs WLST to navigate from the Runtime MBean hierarchy to the Administration MBean hierarchy in an Administration Server instance:
wls:/mydomain/runtime> config() wls:/mydomain/config>

The following example instructs WLST to navigate from the Runtime MBean hierarchy to the Administration MBean hierarchy and back, in an Administration Server instance:
wls:/mydomain/runtime> cd(ServerRuntimes/myserver) wls:/mydomain/runtime/ServerRuntimes/myserver> config() wls:/mydomain/config> cd(Servers/myserver/SSL/myserver)> wls:/mydomain/config/Servers/myserver/SSL/myserver> runtime() wls:/mydomain/runtime/ServerRuntimes/myserver>

ADMINCONFIG
The ADMINCONFIG command is available only when WLST is connected to an Administration Server instance. When connected to an Administration Server instance, the ADMINCONFIG command places WLST at the root of the Local Configuration MBeans. Entering the ADMINCONFIG command to navigate back to a Local Configuration MBean from an Administration MBean or the runtime hierarchy, places WLST at the Local Configuration MBean to which you last navigated.

Syntax
adminConfig()

Example
The following example instructs WLST to navigate from the Administration MBean hierarchy to the Local Configuration MBean hierarchy on a Administration Server:
wls:/mydomain/config> adminConfig() wls:/mydomain/config> ls() dr-dr-dr-dr-dr-ApplicationManagerConfig ApplicationsConfig BasicRealmsConfig BridgeDestinationCommonConfig BridgeDestinationConfig

2-26

Using the WebLogic Server Scripting Tool

CUSTOM

dr-dr-dr-dr-dr-...

CachingRealmsConfig ClustersConfig ConversationServiceConfig DomainLogFilterConfig EmbeddedLDAPConfig

CUSTOM
The CUSTOM command is available when WLST is connected to an Administration Server instance or a Managed Server instance. The command places WLST at the root of Custom MBeans that are registered in the server. WLST navigates, interrogates, and edits Custom MBeans as it does Administration MBeans, however, Custom MBeans cannot use the CMO variable because a stub is not available. When connected to a WebLogic Integration (WLI) or WebLogic Portal (WLP) Server, WLST can interact with all the WLI or WLP Server MBeans. For more information on Custom MBeans, see "Non-WebLogic Server MBeans" in Programming WebLogic Management Services with JMX.

Syntax
custom()

Example
The following example instructs WLST to navigate from the Configuration MBean hierarchy to the Custom MBean hierarchy on a Administration Server instance:
wls:/mydomain/config> custom() wls:/mydomain/CUSTOM>

RUNTIME
Navigates to the root of all runtime objects, DomainRuntimeMBean, and sets the CMO variable to DomainRuntimeMBean. When connected to a Managed Server instance, the root of Runtime MBeans is ServerRuntimeMBean. Entering the RUNTIME command from the Administration or Local Configuration MBean hierarchy again, places WLST at the Runtime MBean to which you last navigated.

Using the WebLogic Server Scripting Tool

2-27

Usin g t h e W ebL ogi c S erver Scripting T ool

For more information, see Browsing the Runtime Information on page 2-15.

Syntax
runtime()

Example
The following example instructs WLST to navigate from the Local Configuration MBean hierarchy to the Runtime MBean hierarchy on a Managed Server instance:
wls:/mydomain/config> runtime() wls:/mydomain/ServerRuntime/managed1>

The following example instructs WLST to navigate from the Local Configuration MBean hierarchy to the Runtime MBean hierarchy and back, on a Managed Server instance:
wls:/mydomain/config/ServersConfig/managed1> runtime() wls:/mydomain/runtime/ServerRuntime/managed1> cd(JVMRuntime/managed1) wls:/mydomain/runtime/ServerRuntime/managed1/JVMRuntime/managed1> config() wls:/mydomain/config/ServersConfig/managed1>

Edit Commands
Table 2-4 describes commands you use to interrogate and edit MBeans using WLST online and offline. When connected to a Managed Server instance, you cannot use the SET, INVOKE, or CREATE commands. Table 2-4 Edit Commands Command
GET

Description
Return the value of the current MBean attribute. See GET on page 2-29.

SET

Set MBean attributes. This command cannot be used for Runtime MBeans. See SET on page 2-29.

INVOKE

Invoke a management operation that an MBean exposes for its underlying resource. See INVOKE on page 2-30.

2-28

Using the WebLogic Server Scripting Tool

GET

Table 2-4 Edit Commands (Continued)


CREATE

Return a newly created child MBean. See CREATE on page 2-31.

DELETE

Delete an MBean instance. See DELETE on page 2-32.

SAVEDOMAIN

Saves the current configuration to the configuration file, typically config.xml. See SAVEDOMAIN on page 2-32.

GET
Returns the value for the current MBean attribute.

Syntax
get(AttributeName)

Argument
AttributeName

Definition
Name of the MBean attribute to be displayed.

Example
The following example returns the value of the ArchiveConfigurationCount for the current MBean:
wls:/mydomain/config> get('ArchiveConfigurationCount') 5 wls:/mydomain/config>

An equivalent command to get('ArchiveConfigurationCount',10) is


cmo.getArchiveConfigurationCount(10).

SET
Sets the specified attribute values for the current MBean. When you use this command for an Administration MBean, the new values are saved in the config.xml file. BEA Systems
Using the WebLogic Server Scripting Tool 2-29

Usin g t h e W ebL ogi c S erver Scripting T ool

recommends that you do not use this command to set values in a Local Configuration MBean. If you use this command for a Local Configuration MBean, the new values are not saved to the config.xml file. Depending on the attribute that you set, the subsystem that uses the MBean might not be able to modify its operation per the new value. In addition, some subsystems require that their Local Configuration MBeans be replicated throughout a domain. If you modify the value for a Local Configuration MBean on one server, the new value will not be replicated throughout the domain and the subsystem might not operate correctly. You cannot use the SET command when WLST is connected to a Managed Server instance.

Syntax
set(AttributeName,AttributeValue)

Argument
AttributeName AttributeValue

Definition
Name of the MBean attribute to be set. Value of the MBean attribute to be set.

Example
The following example sets the ArchiveConfigurationCount attribute of DomainMBean to 10:
wls:/mydomain/config> set('ArchiveConfigurationCount',10) wls:/mydomain/config>

An equivalent command to set('ArchiveConfigurationCount',10) is


cmo.setArchiveConfigurationCount(10).

INVOKE
Invokes a management operation on the current MBean. Typically, you use this command to invoke operations other than the GET and SET operations that most WebLogic Server MBeans provide. You cannot use the INVOKE command when WLST is connected to a Managed Server instance.

Syntax
invoke(methodName,Parameters,Signatures)

2-30

Using the WebLogic Server Scripting Tool

CREATE

Argument
methodName Parameters Signatures

Definition
Name of the method to be invoked. An array of parameters to be passed to the method call. An array containing the signature of the action.

Example
The following example calls the discoverManagedServer method on the current MBean:
wls:/mydomain/config> objs = jarray.array([java.lang.String("oamserver")],java.lang.Object) wls:/mydomain/config> strs = jarray.array(["java.lang.String"],java.lang.String) wls:/mydomain/config> invoke('discoverManagedServer',objs,strs) true wls:/mydomain/config>

CREATE
Creates an instance of a WebLogic Server Administration or Local Configuration MBean that is a child of the current MBean type, however, BEA Systems recommends that you do not use it to create Local Configuration MBeans. This command cannot be used for Runtime MBeans or when WLST is connected to a Managed Server instance. For more information on creating MBeans, see "Commands for Managing WebLogic Server MBeans" in WebLogic Server Command Reference.

Syntax
create(Name,childMBeanType)

Argument
Name

Definition
Name for the MBean that you are creating.

Using the WebLogic Server Scripting Tool

2-31

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
childMBeanType

Definition (Continued)
Type of child MBean that you are creating. For more information, see "Specifying

MBean Types" in WebLogic Server Command Reference.

Example
The following example creates a child MBean named managedServer on an Administration Server instance:
wls:/mydomain/config> create('managedServer','Server') Server with name 'managedServer' has been created successfully. wls:/mydomain/config>

DELETE
Deletes an MBean instance.

Syntax
delete(Name,childMBeanType)

Argument
Name childMBeanType

Definition
Name of the MBean to delete. Deletes MBean of the specified name and type.

Example
The following example deletes the MBean named managedServer:
wls:/mydomain/config> delete('managedServer','Server') Deletion of MBean with name 'managedServer' and type 'Server' successful. wls:/mydomain/config>

SAVEDOMAIN
Saves the current configuration information to a configuration file, typically config.xml. This command is useful only when WLST is connected to an Administration Server.

2-32

Using the WebLogic Server Scripting Tool

Depl oyment Comma nd s

Syntax
saveDomain()

Example
The following command saves the current configuration:
wls:/mydomain/config> saveDomain()

Deployment Commands
Table 2-5 describes commands for deploying, undeploying, and redeploying applications and standalone modules to a WebLogic Server instance. For more information on deploying WebLogic Server applications, see "Overview of WebLogic Server Deployment" in Deploying WebLogic Server Applications. The deploy commands are only applicable while using WLST online. Table 2-5 Deploy Commands Command
DEPLOY

Description
Deploy an application. See DEPLOY on page 2-33.

UNDEPLOY

Stop the deployment of an application. See UNDEPLOY on page 2-34.

REDEPLOY

Replaces a running application. See REDEPLOY on page 2-35.

DEPLOY
Deploys an application to a WebLogic Server instance. For more information on deploying applications, see "Quickstart Guide to Deployment" in Deploying WebLogic Server Applications.

Syntax
deploy(appName,path,[targets],[stageMode])

Using the WebLogic Server Scripting Tool

2-33

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
appName path targets

Definition
Deployment name for the application or standalone module to be deployed. Location of the application or standalone module to be deployed. Optional. A comma-separated list of the target servers. Each target may be qualified with a J2EE module name (for example, module1@server1); this argument lets you deploy different modules of the application archive on different servers. If not specified, the application is not deployed to a server.

stageMode

Optional. The staging mode for the application you are deploying; valid values are stage, nostage, and external_stage.

Example
The following example instructs WLST to deploy myApp application to the listed servers:
wls:/mydomain/config> deploy('myApp','c:/myapps/myapp.ear','mywar@webserver,myjar@ejbserver') Deployment of myApp successful wls:/mydomain/config>

UNDEPLOY
Stops the deployment of an application. For more information on undeploying applications, see "Performing Common Deployment Tasks" in Deploying WebLogic Server Applications.

Syntax
undeploy(appName,[targets])

Argument
appName targets

Definition
Deployment name for the deployed application. Optional. List of the target servers from which the application will be removed. If not specified, defaults to all current targets.

2-34

Using the WebLogic Server Scripting Tool

REDEPLOY

Example
The following example instructs WLST to remove myApp application from all target servers:
wls:/mydomain/config> undeploy('myApp') Undeployment of 'myApp' is successful wls:/mydomain/config>

REDEPLOY
Reloads classes and redeploys a previously deployed application. For more information on redeploying applications, see "Performing Common Deployment Tasks" in Deploying WebLogic Server Applications.

Syntax
redeploy(appName)

Argument
appName

Definition
Deployment name for the application to be redeployed.

Example
The following example instructs WLST to redeploy myApp application to all target servers:
wls:/mydomain/config> redeploy('myApp') Redeployment of 'myApp' is successful wls:/mydomain/config>

Life Cycle Commands


Table 2-6 is an overview of commands that manage the life cycle of a server instance. For more information about the life cycle of a server instance, see "Server Life Cycle" in Configuring and Managing WebLogic Server. The server life cycle commands are only applicable while using WLST online, except STARTSERVER.

Using the WebLogic Server Scripting Tool

2-35

Usin g t h e W ebL ogi c S erver Scripting T ool

Table 2-6 Life Cycle Commands Command


SHUTDOWN

Description
Gracefully shut down a WebLogic Server instance or cluster. See SHUTDOWN on page 2-36.

START

Start a Managed Server instance or a cluster using a configured Node Manager. See START on page 2-37.

SUSPEND

Make a server unavailable to receive requests from external clients. See SUSPEND on page 2-38.

RESUME

Make a server available to receive requests from external clients. See RESUME on page 2-39.

STARTSERVER

Start the Administration Server. See STARTSERVER on page 2-39.

SHUTDOWN
Shuts down a running server instance or a cluster. This command waits for all the in-flight work to be completed before shutting down a server or cluster. When connected to a Managed Server instance, you only use the SHUTDOWN command to shutdown the Managed Server instance to which WLST is connected; you cannot shutdown another server while connected to a Managed Server instance. You shutdown a server to which WLST is connected by entering the SHUTDOWN command without any arguments.

Syntax
shutdown([Name of Server or Cluster], [Type(Server/Cluster)], [ignoreSessions],[timeOut],[force])

Argument
Name Type

Definition
Optional. Name of the server or cluster to shutdown. Optional. Server or Cluster.

2-36

Using the WebLogic Server Scripting Tool

STA RT

Argument
ignoreSessions

Definition (Continued)
Optional. Boolean. Specifies whether WLST should drop all HTTP sessions immediately or wait for HTTP sessions to complete or timeout while shutting down. Optional. Number of seconds subsystems have to complete in-flight work and suspend themselves. Optional. Boolean. Specifies whether WLST should terminate a server instance or a cluster without waiting for the active sessions to complete.

timeout

force

Example
The following example instructs WLST to wait 1000 seconds for HTTP sessions to complete or timeout before shutting down myserver:
wls:/mydomain/config> shutdown(myserver,Server,false,1000) ...

The following example instructs WLST to drop all HTTP sessions immediately while connected to a Managed Server instance:
wls:/mydomain/config> shutdown('m1','Server',true,1200) Shutting down a managed server that you are connected to ... Disconnected from weblogic server: m1 wls:/(offline)> The scripting shell lost connection to the server that you were connected to, this may be because the server was shutdown or partitioned. You will have to re-connect to the server once the server is available.

START
Starts a Managed Server instance or a cluster using a configured Node Manager. Note: This command requires that a Node Manager is configured and running. For more information, see "Overview of Node Manager" in Configuring and Managing WebLogic Server.

Syntax
start([Type(Server/Cluster)],[Name of Server or Cluster], [ListenAddress],[ListenPort])

Using the WebLogic Server Scripting Tool

2-37

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
Type Name ListenAddress ListenPort

Definition
Optional. Server or Cluster. Optional. Name of the Managed Server or cluster to start. Optional. Listen address of the Managed Server. Optional. Listen port of the Managed Server.

Example
The following example instructs the Node Manager to start a Managed Server instance whose listen address is localhost and listen port is 8801:
wls:/mydomain/config> start('Server','managed1','localhost',8801) Starting server 'managed1' ... The server 'managed1' started successfully. wls:/mydomain/config>

SUSPEND
Moves a server from the RUNNING state to the STANDBY state. For more information about server states, see "Server Life Cycle" in Configuring and Managing WebLogic Server.

Syntax
suspend(ServerName)

Argument
ServerName

Definition
Name of the server to suspend.

Example
The following example instructs WLST to suspend a Managed Server instance:

2-38

Using the WebLogic Server Scripting Tool

RESUME

wls:/mydomain/config> suspend('managed1') Server 'managed1' suspended successfully. wls:/mydomain/config>

RESUME
Moves a server from the STANDBY state to the RUNNING state. Use this command to resume a WebLogic Server instance that is suspended. For more information about server states, see "Server Life Cycle" in Configuring and Managing WebLogic Server.

Syntax
resume(ServerName)

Argument
ServerName

Definition
Name of the server to resume.

Example
The following example instructs WLST to resume a Managed Server instance:
wls:/mydomain/config> resume('managed1') Server 'managed1' was resumed successfully. wls:/mydomain/config>

STARTSERVER
Starts the Administration Server.

Syntax
startServer([adminServerName],[domainName],[url],[username],[password], [domainDir],[block],[timeout])

Using the WebLogic Server Scripting Tool

2-39

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
adminServerName

Definition
Optional. Name of the Administration Server to start. If not specified, WLST uses the default server name, myserver. Optional. Name of the domain to which the Administration Server belongs. If not specified, WLST uses the default domain name, mydomain. Optional. URL of the Administration Server. If not specified, WLST uses the default URL, t3://localhost:7001. Optional. Username for connecting WLST to the server. If not specified, WLST uses the default username, weblogic. Optional. Password for connecting WLST to the server. If not specified, WLST uses the default password, weblogic. Optional. Domain directory in which the Administration Server is being started. If not specified, WLST uses the current directory in which WLST is running. Optional. When set to true, specifies that WLST block user interaction until the server is started. Default = false; control returns to the user after issuing the command. Optional. Time in milliseconds that WLST waits for the server to start. The default value is 60000 milliseconds. This argument is only applicable when block = true.

domainName

url

username

password

domainDir

block

timeout

Example
The following example instructs WLST to start the Administration Server:
wls:/offline> startServer('demoServer','demoDomain','t3://sghattu:8001','myweblogic', 'wlstdomain','c://mydomains/wlst') wls:/offline>

Information Commands
Table 2-7 describes informational commands useful for interrogating domains, servers, and variables, and providing MBean and WLST-related information.

2-40

Using the WebLogic Server Scripting Tool

Inf or mat io n Comma nd s

Table 2-7 Information Commands Command


PROMPT

Description
Hide the MBean navigation path information in the prompt. See PROMPT on page 2-42.

PWD

Show the current location in the MBean hierarchy. See PWD on page 2-42.

LS

List all the MBean types contained in the current MBean. See LS on page 2-43.

STATE

Return the state of a server or cluster. See STATE on page 2-45.

HELP

Display syntax and usage information for a command. See HELP on page 2-46.

DUMPVARIABLES

Display all the variables and their values. See DUMPVARIABLES on page 2-47.

DUMPSTACK

Display the stack trace from the last exception that occurred. See DUMPSTACK on page 2-47.

LOADPROPERTIES

Gets values from a properties file and sets them on WLST. See LOADPROPERTIES on page 2-48.

MAN

Displays context-based Help information for the MBean instance to which WLST navigates. See MAN on page 2-48.

STARTRECORDING

Start recording commands. See STARTRECORDING on page 2-49.

STOPRECORDING

Stop recording commands. See STOPRECORDING on page 2-49.

Using the WebLogic Server Scripting Tool

2-41

Usin g t h e W ebL ogi c S erver Scripting T ool

PROMPT
Hides the MBean navigation path information at the prompt, when entered without an argument. Useful when the prompt becomes lengthy due to the MBean navigation path. Entering the PROMPT command again, redisplays the MBean navigation path information. To determine the current location in the MBean hierarchy, enter the PWD command. When entered with the OFF argument, the PROMPT command hides the WLST prompt and defaults to the Jython prompt. You can create a new prompt using Jython syntax.

Syntax
prompt([off|on])

Argument
off | on

Definition
Optional. Hides or displays WLST prompt.

Example
The following example instructs WLST to hide and redisplay the MBean navigation path information at the prompt:
wls:/mydomain/config/Servers/myserver> prompt() wls:/> wls:/> prompt() wls:/mydomain/config/Servers/myserver>

The following example instructs WLST to hide, change, and redisplay the WLST prompt:
wls:/mydomain/config> prompt('off') >>> >>>sys.ps1="myprompt>" myprompt> myprompt> prompt('on') wls:/mydomain/config>

PWD
Shows the current location in the MBean hierarchy.

2-42

Using the WebLogic Server Scripting Tool

LS

Syntax
pwd()

Example
The following command displays the current location in the MBean hierarchy:
wls:/mydomain/config/Servers/myserver/Log/myserver> pwd() '/Servers/myserver/Log/myserver'

LS
Displays all the MBean types, attributes, or operations of the current MBean, depending on an optional argument. The parameter choices are listed in the syntax arguments table. If no argument is specified, the command lists all the child MBeans. If there are no child MBeans, the command displays the attributes. The output is returned as a string. Table 2-8 describes the LS command output information. Table 2-8 LS Command Output Information
Output d r w x Definition An MBean with which you can use the CD command; analogous to a directory in a UNIX or Windows file system. A readable property. A writeable property. An executable operation.

Syntax
ls([o][c][a])

Argument
o

Definition
Optional. Display all the operations that can be invoked on the current Runtime MBean. Operations are not shown for Administration or Local Configuration MBeans. Optional. Display all the child MBeans that are contained in the current MBean.

Using the WebLogic Server Scripting Tool

2-43

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
a

Definition (Continued)
Optional. Display all the attribute names and values for the current MBean. If the attribute is encrypted, WLST displays six asterisks (*).

Example
The following command displays all the child MBeans in DomainMBean:
wls:/mydomain/config> ls() drwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrwdrw... ApplicationManager Applications BasicRealms BridgeDestination BridgeDestinationCommon CachingRealms Clusters ConversationService DomainLogFilter EmbeddedLDAP FileRealm FileT3s ForeignJMSServer HTTPProxy JDBCConnectionPools

The following command displays all the attribute names and values in DomainMBean:
wls:/mydomain/config> ls('a') -rw-rw-rw-r--rw-rw-rw-r--rw-rwAdministrationPort AdministrationPortEnabled ArchiveConfigurationCount CachingDisabled ClusterConstraintsEnabled ConfigurationVersion ConsoleEnabled DisconnectedManagedServers EmbeddedLDAP JTA 9002 false 10 true false 8.1.2.0 true [Ljava.lang.Object;@144b364 mydomain:Name=mydomain,Type=JTA

mydomain:Name=mydomain,Type=EmbeddedLDAP

2-44

Using the WebLogic Server Scripting Tool

S T AT E

-r--rw-rw-rw-rw-rw-rw-r--r--rw-rw-rw-rw-

LastModificationTime Log Name Notes ObjectName Parent ProductionModeEnabled Registered RootDirectory SNMPAgent Security SecurityConfiguration Servers

0 mydomain:Name=mydomain,Type=Log mydomain null mydomain:Name=mydomain,Type=Domain null false false . mydomain:Name=mydomain,Type=SNMPAgent mydomain:Name=mydomain,Type=Security

mydomain:Name=mydomain,Type=SecurityConfiguration mydomain:Name=managed2,Type=Server|mydomain:Name=managed8,Type=Server|mydo main:Name=managed1,Type=Server|mydomain:Name=myserver,Type=Server|mydomain :Name=managed7,Type=Server|mydomain:Name=managed4,Type=Server|mydomain:Nam e=managed9,Type=Server|mydomain:Name=managed5,Type=Server|mydomain:Name=ma naged6,Type=Server|mydomain:Name=managed3,Type=Server|mydomain:Name=manage dServer,Type=Server|mydomain:Name=managed10,Type=Server -r-Type Domain -rwWTCServers wls:/mydomain/config>

STATE
Returns the state of a server or cluster. For more information about server states, see "Server Life Cycle" in Configuring and Managing WebLogic Server.

Syntax
state(Name,[Type])

Argument
Name

Definition
The name of the server or cluster for which you want to retrieve the current state.

Using the WebLogic Server Scripting Tool

2-45

Usin g t h e W ebL ogi c S erver Scripting T ool

Argument
Type

Definition (Continued)
Optional. Server or Cluster. Default = Server.

Example
The following example returns the state of a Managed Server:
wls:/mydomain/config> state('managed1','Server') Current state of 'managed1': SUSPENDED wls:/mydomain/config>

HELP
Provides syntax and usage information for all categories of WLST commands, when no arguments are specified, or for a single command, when a command name argument is specified. The HELP command will support a query; for example, HELP(get*) displays the syntax and usage information for all commands that begin with get.

Syntax
help(command_name)

Argument
command_name

Definition
Command name for which information is requested.

Example
In the following example, information about using the FORCESHUTDOWN command is requested:
wls:/mydomain/config> help('shutdown')

The command returns the following:


Description: Gracefully shuts down the server. Syntax: shutdown([Name of Server or Cluster], [Type(Server/Cluster)],[ignoreSessions],[timeOut],[force])

2-46

Using the WebLogic Server Scripting Tool

DUMPVARIABLES

Name [optional] = Name of the Server or Cluster that is to be shut down Type [optional] = The Type, Server or Cluster. ignoreSessions [optional] = Ignore any sessions before shutting down timeOut [optional] = Times out after this time force [optional] = If 'true' will shutdown the server forcefully. Example: wls:/mydomain/config>shutdown("myserver","Server","false",1000)

DUMPVARIABLES
Displays all the variables that WLST uses, the variable names, and their values.

Syntax
dumpVariables()

Example
This example instructs WLST to display all the current variables and their values.
wls:/mydomain/config> dumpVariables() cmo connected domainName username isAdminServer serverName version recording exitonerror wls:/mydomain/config> [Caching Stub]Proxy for mydomain:Name=mydomain,Type=Domain true mydomain weblogic true myserver WebLogic Server 8.1 SP2 Mon Oct 27 22:57:18 PST 2003 305727 Mon Oct 27 22:57:18 PST 2003 305727 false true

WebLogic XMLX Module 8.1 SP2

DUMPSTACK
Prints the stack trace from the last exception that occurred while executing a WLST command.

Syntax
dumpStack()

Using the WebLogic Server Scripting Tool

2-47

Usin g t h e W ebL ogi c S erver Scripting T ool

LOADPROPERTIES
Gets values from a properties file and sets them.

Syntax
loadProperties(propertiesFile)

Argument
propertiesFile

Definition
Properties file pathname.

Example
This example instructs WLST to get and set the properties file values:
wls:/mydomain/config> loadProperties(c:/temp/myLoad.properties)

MAN
Displays context-based information for the MBean instance to which WLST navigates.

Syntax
man([name][a][o][c])

Argument
name a o c

Definition
Optional. Display information for the attribute. Optional. Display information for all the attributes of the current MBean instance. Optional. Display information for all the operations of the current MBean instance. Optional. Display information for all the children MBeans.

Example
This example instructs WLST to display Help information for all the attributes of the current MBean instance:

2-48

Using the WebLogic Server Scripting Tool

STARTRECORDING

wls:/mydomain/config> man('a')

STARTRECORDING
Records all user interactions with WLST; useful for capturing commands.

Syntax
startRecording(recordFilePath)

Argument
recordFilePath

Definition
File pathname for storing WLST commands.

Example
The following example instructs WLST to begin recording WLST commands in the record.py file:
wls:/mydomain/config> startRecording(c:/myScripts/record.py) Starting recording to c:\myScripts\record.py

STOPRECORDING
Stops recording WLST commands.

Syntax
stopRecording()

Example
The following example instructs WLST to stop recording WLST commands:
wls:/mydomain/config> stopRecording() Stopping recording c:\myScripts\record.py

Using the WebLogic Server Scripting Tool

2-49

Usin g t h e W ebL ogi c S e rver Scripting T ool

Script Generation
Script generation converts resources that are configured in the config.xml file to an executable WLST script that you can use to recreate the resources on other servers. WLST need not be connected to a WebLogic Server instance to execute this command.

CONFIGTOSCRIPT
The CONFIGTOSCRIPT command converts an existing server configuration file (config.xml) to an executable WLST script. When you run the generated script, it starts a new WebLogic Server instance (if invoked from an empty directory), and enters WLST script commands against the server to create the server resources.

Syntax
configToScript(configPath,scriptPath,[overwrite],[resourceList],[createDel eteFile])

Argument
configPath scriptPath overwrite resourceList createDeleteFile

Definition
Location of the config.xml file to be converted. File pathname of the script file that is created. Optional. If set to True, overwrites the script file. Optional. A comma-separated list of resources to be converted. Optional. If set to True, creates a script that deletes the resources created using the CONFIGTOSCRIPT command.

Example
The following example converts server resources configured in a config.xml file to a WLST script config.py:
wls:/(offline)> configToScript('c:/bea/user/mydomain/config.xml', 'c:/temp/wlst/config.py') Converting resource ... DomainLogFilter\OAMdomainLogFilter Converting resource ... Server\adminServer Converting resource ... SSL\adminServer

2-50

Using the WebLogic Server Scripting Tool

R un ni ng Sc ri pt s

Converting resource ... XMLRegistry\registry_default Converting resource ... XMLEntitySpecRegistryEntry\myXMLEntitySpecRegistryEntry Converting resource ... XMLRegistryEntry\myXMLRegistryEntry Converting resource ... DomainLogFilter\wnewDomainLogFilter ConfigToScript Successfully completed:, 7 resources are converted. wls:/(offline)>

Running Scripts
Scripts lets you supply a sequence of WLST commands in a file that the tool invokes without requiring your input, much like a shell script.

EXECFILE
To run a WLST script, enter the EXECFILE command.

Syntax
execfile(filePath)

Argument
filePath

Definition
File pathname of WLST script.

Table 2-9 describes WLST example scripts that you can use as templates for creating additional scripts. Table 2-9 WLST Example Scripts Script
example.py

Description
Connects to an Administration Server instance, creates Managed Servers, creates clusters, assigns servers to each cluster, disconnects WLST from the server, and exits the scripting shell. See Example on page 2-52.

Using the WebLogic Server Scripting Tool

2-51

Usin g t h e W ebL ogi c S e rver Scripting T ool

Table 2-9 WLST Example Scripts (Continued)


security.py

Defines a security class that can be instantiated. To create an instance of the security class, enter the command:
mySecurity=security()

After creating an instance of the security class, you can call methods, such as mySecurity.listUsers, which lists all the users in the default realm.
jdbcUtil.py

Defines a some basic JDBC utility functions.

Example
The example.py script instructs WLST to perform the following steps: 1. Connect to an Administration Server instance. 2. Create ten Managed Servers. The server names and listen ports are saved in variables that you can edit when moving resources. 3. Create two clusters (cluster1 and cluster2). 4. Assign the first five Managed Servers to cluster1 and the other five to cluster2. 5. Disconnect from the server and exit the scripting shell.
wls:/(offline)> execfile(c:/temp/example.py) starting the script .... Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ... Successfully connected. creating cluster cluster1 creating cluster cluster2 creating managed server managed3 creating managed server managed2 creating managed server managed1 creating managed server managed5 creating managed server managed4 creating managed server managed10 creating managed server managed9 creating managed server managed8 creating managed server managed7 creating managed server managed6 Disconnected from weblogic server: myserver End of script ...

2-52

Using the WebLogic Server Scripting Tool

E XE C F I L E

Exiting WLS scripting shell ... C:\>

Using the WebLogic Server Scripting Tool

2-53

Usin g t h e W ebL ogi c S erver Scripting T ool

2-54

Using the WebLogic Server Scripting Tool

Potrebbero piacerti anche