Working with the Portal Scripting Interface
Use the Portal Scripting Interface in any of the following ways:
Interactive mode
Use the interactive mode if you do not intend to repeat the operation.
Before initating a session in interactive mode, verify WebSphere Portal is running...
serverStatus.sh YourPortalServer
Invoke the portal script client by running....
WPS_HOME/bin/wpscript.shFor example...
- If WAS security is disabled, run...
wpscript.sh -port 8882
If WAS security is enabled, the scripting tool must receive a User ID and password during login.
wpscript.sh -port 8882 -user wpsadmin -password wpsadminConnection options include...
Value Description -conntype The type of connection that should be established between scripting. Valid connection types include: The default value is SOAP. This parameter is optional. Use the -conntype NONE option to run in local mode. The result is that the scripting client is not connected to a running server. If the connection type NONE is selected, the scripting beans are inactive and cannot be used for administration, with the exception of the help command.
-port The name of the connection port. The default port is 8882. This parameter is optional. If you are running wpscript on a machine that is part of a cluster use -port 8879 instead of -port 8882.
- Log on to the portal using the following script command:
$Portal login wpsadmin wpsadmin- Issue portal script commands as required.
- After you have completed all tasks by the portal scripting interface, close and exit the script processor. All changes that you committed are applied to the portal configuration.
Script mode
Use the script mode to apply predefined changes to the configuration of a portal. The wpscript tool executes a JACL script that contains the administrative operations.
To launch the script processor tool execute...
wpscript -f program.jaclFor example...
wpscript.sh -port 8882 -f testme.jacl portaladmin adminpwd...where testme.jacl contains...
### ### testme.jacl ### ### Create a new page with the title "A page". This page resides ### below the "My Portal" label. The page contains two portlets, ### which are arranged horizontally. ### proc create_multi_col_page { name portlet_names } { global Content Layout Portlet set thePage [$Content create page $name html] $Content select $thePage set lyt0 [$Layout create container horizontal select] foreach pn $portlet_names { set pid [$Portlet find portlet cn $pn] $Layout create control $pid } return $thePage } set user portaladmin set pwd adminpwd $Portal login $user $pwd $Content select [$Content find all uniquename "wps.My Portal"] set newbie [create_multi_col_page "A Page" { "World_Clock" "Welcome_to_WebSphere_Portal" } ] puts "ok, we are done."All changes are immediately applied to the portal configuration. For a list of available commands, see Command reference for Portal Scripting Interface.
The scripts can receive parametric information externally, by using one of the JACL feature listed below:
- Profiles
- Command line arguments
A JACL script can access command line arguments with the JACL scripting variables argc (that holds the number of command line arguments) and argv (that holds the command line arguments themselves).
Example: In the "testme.jacl" portal script file shown above, delete the following statements:
set user portaladmin set pwd adminpwdand replace it with the following code:
if { $argc != 2 } { fail "invocation syntax: wpscript testme.jacl <user> <pwd>" } set user [lindex $argv 0] set pwd [lindex $argv 1]The security-sensitive user name and password are removed from the JACL script. The modified code expects the user ID and password to be specified as command line arguments, for example:
Run scripting commands in a profile
A profile is a script that runs before the main script, or before entering interactive mode. Profiles can be used to set up environment specific behavior or user specific data. Profiles are specified when invoking wpscript, using the -profile parameter. For example, the login command can be placed in a profile. The following example of a profile, which we'll call "mylogin.jacl", would look like this:
if { $argc != 2 } { fail "invocation syntax: wpscript -f testme.jacl -profile mylogin.jacl <user> <pwd>" } set user [lindex $argv 0] set pwd [lindex $argv 1] $Portal login $user $pwdRemove or comment out the following statements in the "testme.jacl" script file:
if { $argc != 2 } { fail "invocation syntax: wpscript testme.jacl <user> <pwd>" } set user [lindex $argv 0] set pwd [lindex $argv 1] $Portal login $user $pwdThen, invoke the "mylogin.jacl" script as follows:
wpscript.bat -port 8882 -profile mylogin.jacl -f testme.jacl portaladmin adminpwdThe benefit of this change is that the environment-specific login procedure is extracted from the administration script. For systems with enabled WAS security, it is as follows:
$Portal login
Prerequisites
The portal scripting interface works under all operating systems that WebSphere Portal supports.
The same prerequisites that apply for the for the scripting tool of $WebSphere Application Server must be fulfilled, especially the following prerequisites:
- MBean server
- Scripting client.
The WebSphere Portal package provides starter scripts as follows:
- UNIX: wpscript.sh
- Windows: wpscript.bat
- For iSeries systems: wpscript.sh
- For z/OS systems: wpscript.sh
Insert RHPP above.
Limitations
The following limitations apply to the Portal Scripting Interface:
- The functionality provided by WP5.1 mainly targets content hierarchy and layout configurations. Use it to add, delete, or update content nodes, such as pages, labels, and links.
- The Portal Scripting Interface works only for portal core / foundation functions.
- When you use the Portal Scripting Interface, you have to observe the following limitations with regard to virtual portals:
- You can be connected to only one virtual portal at a given time.
- You can make updates to only one virtual portal at a given time.
- The Portal Scripting Interface does not support the following functions that are provided by the portal user interface:
- User and group management
- Portal analysis
- Cloning and parameterization of portlets and portlet applications
- Some esoteric attributes and flags may not be accessible
- Transactions spanning multiple script command executions are not supported.
The current implementation of the wsamdin extensions requires use of semi public APIS from WAS. The WAS wsadmin team is working on new APIs to better support script component extensions. The Portal script component should be migrated to exploit these APIs when they become available. One other enhancement that is expected will introduce a namespace concept for BSF command beans.
See also
- Portal Scripting Interface
- About the Portal Scripting Interface
- Command reference for the Portal Scripting Interface
- Portal configuration
- The XML configuration interface
- Administering your portal
Home |
WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.