OpenText product name changes coming to the community soon! Learn more.

Wikis - Page

stcmdEx - A Stateless Command Line Execution Environment and alternative to stcmd

0 Likes

stcmdEx.jar is a stateless, non-interactive command line batch execution engine targeted as a lightweight alternative to stcmd.exe.

stcmdEx.jar is automatically distributed with all 14.0 SDK  or CPC installers.

stcmdEx can be directly integrated into existing Microsoft Windows batch files (or Unix shell scripts) using the following syntax:

java.exe -jar stcmdEx.jar command-line-command-with-parameters

e.g., on Windows...
"C:\Program Files\Micro Focus\StarTeam Cross-Platform Client 17\jre\bin\java.exe" -jar "C:\Program Files\Micro Focus\StarTeam Cross-Platform Client 17\stcmdEx.jar" co /p \"Administrator:Administrator@localhost:49201/Project Name/View Name\" /is /rp \"c:\temp\" /filter \"GIMOU\" /o /vb >c:\temp\output.txt

Note: When passing command arguments within Microsoft Windows command prompts or bat files, "
needs to be escaped with a \ so that the " itself gets streamed as part of the argument.

On Microsoft Windows platforms, stcmdEx can be incorporated into its own .bat file if necessary. Add the next two lines to a .bat file (stcmdEx.bat), which may then be called from a driving batch script. use %* to pass all parameters individually quoted as passed to the command batch script itself.

@echo ON

"C:\Program Files\Micro Focus\StarTeam Cross-Platform Client 17\jre\bin\java.exe" -jar "C:\Program Files\Micro Focus\StarTeam Cross-Platform Client 17\stcmdEx.jar" %*

  

  

  

similarly, it may be  embedded in a unix (bash) shell script where you use "$@" to pass all parameters individually quoted as passed to the script itself.

#!/usr/bin/env bash
java -jar /path/to/stcmdEx.jar "$@"

 

Using stcmdEx. you can run the command line engine with no local client server dependency, as long as every command issued through this script uses -p, i.e. is stateless. In addition, you can run command line jobs in parallel, since stcmdEx launches the SDK in process, executes the command, returns the results, then releases the SDK.

This model differs from stcmd, which is a fully stateful engine. stcmd supports the ability to connect to the starteam server, set a project/view/folder(s) context, then execute a series of commands, changes the project/view/folder(s) context, finally disconnect. To provide a stateful context, stcmd is client-server on your local machine. hence stcmd.exe launches an stcmd client in process which opens a socket connection to a running stcmd server on the local machine, which in turn maintains the connection context to the StarTeam server across the network. As a result, a sequence of stcmd commands may be executed which launch and release the stcmd client as they run, leaving the local stcmd server up and running. While this covers all single batch script use cases, it does not support multiple batch scripts possibly running in parallel on the same machine.

 

Since stcmdEx on the other hand launches and runs the SDK in process, multiple parallel invocations of the script will each run in their own process spaces (jre runtime). Besides supporting batch parallelism, this solution has the inherent advantage of fewer moving parts (processes) involved, and is better suited for integration into scripting environments like Ant or Hudson.

 

The stcmdEx.jar file consists of a manifest, a .java file (StatelessClient.java) and a byte compiled .class file (StatelessClient.class). The java implementation is relatively straightforward, simply invoking the SDK's CommandProcessor engine with the specified parameters.

Note also that (unlike stcmd) stcmdEx is guaranteed to return error codes of 0 on success, 1 on failure for all stateless commands, when executed in a batch script.

 

When executed, command line commands consume as much memory as the data that are required to process. The more the data, the more the memory.

If command execution runs out of heap memory, you may increase it subject to availability on your machine.

32 bit platforms cannot exceed 2GBs. 64 bit platforms cannot exceed the physical memory available.

to run an stcmdEx command with memory management, use

java.exe -Xmx{nnnn}m  -jar stcmdEx.jar "command"

where {nnnn} could be 1024, 2048, 4096, 8192 etc

Labels:

Support Tips/Knowledge Docs
Support Tip
Comment List
Related
Recommended