[opencms-dev] run cmsShell script under Windows

Lambert Gerard Gerard.Lambert at cpln.ch
Fri Sep 30 10:19:45 CEST 2005


The launching of a cmsShell under Windows has problem in raison of the large classpath.
to work around the problem I wrote a build.xml for ant. Here the code:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<project name="shell" default="run" basedir="." >

	<target name="run">
		<java classname="org.opencms.main.CmsShell">
			<arg value="-base=C:\java\Tomcat 5.0\webapps\opencmsesnig\WEB-INF" />
			<classpath>
				<fileset dir="./lib">
					<include name="*.jar"/>
				</fileset>
				<fileset dir="C:\java\Tomcat 5.0\common\lib">
					<include name="*.jar"/>
				</fileset>
			</classpath>
		</java>
	</target>

</project>

This puts you in cmsshell mode and you can launch the commands.
To see the the commands list type help *

I encountered a problem to launch a script.  This is due to an error in the code of the CmsShell class.
In the declaration of the constants we can read:

    /** Prefix for "script" parameter. */
    public static final String SHELL_PARAM_SCRIPT = "-servletMapping=";

    /** Prefix for "servletMapping" parameter. */
    public static final String SHELL_PARAM_SERVLET_MAPPING = "-script=";

To be able to launch a script the parameter -servletMapping should be passed instead of -script.
Our build.xml becomes:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<project name="shell" default="run" basedir="." >

	<target name="run">
		<java classname="org.opencms.main.CmsShell">
			<arg value="-base=C:\java\Tomcat 5.0\webapps\opencmsesnig\WEB-INF" />
			<arg value="-servletMapping=C:\java\Tomcat 5.0\webapps\opencmsesnig\WEB-INF\script.txt"/>

			<classpath>
				<fileset dir="./lib">
					<include name="*.jar"/>
				</fileset>
				<fileset dir="C:\java\Tomcat 5.0\common\lib">
					<include name="*.jar"/>
				</fileset>
			</classpath>
		</java>
	</target>

</project>

Here a sample of file script.txt for users creation :
login Admin admin
createUser usr1 usr1 usr1
createUser usr2 usr2 usr2
addUserToGroup usr1 Administrators
getUsers


Gérard Lambert
-------------------------------------------------------------------------------
esnig
Ecole Supérieure Neuchâteloise d'Informatique de Gestion
Maladière 84
CH-2000 Neuchâtel
-------------------------------------------------------------------------------
Ligne directe : ++41 (0) 32 717 4231
Secrétariat : ++41 (0) 32 717 4080
Fax : ++41 (0) 32 717 4089
-------------------------------------------------------------------------------




More information about the opencms-dev mailing list