                                 CBS Command Line Tool
                                 =====================

In the sequel a brief description of the CBS command line tool is given.
You will find a more detailed description in SAP Netweaver Developer Studio help.

Content: A)   Installation
         B)   Running CBS Tool on Windows Platforms
         B1)   Jars underneath SAP NetWeaver Developer Studio installation folder are used
         B2)   Jars from a separate directory are used
         C)   Running CBS Tool on Linux/Unix Platforms
         D)   First Steps


A)   Installation

The CBS command line tool is part of the SAP NetWeaver Developer Studio installation. 
Assuming that <ROOTPATH> denotes the root installation path of SAP NetWeaver Developer Studio 
you will find a set of files related to the CBS command line tool in directory 
<ROOTPATH>/eclipse/tools/cbstool.

The SAP NetWeaver Developer Studio installation copies the following files into directory <ROOTPATH>/eclipse/tools/cbstool:

cbstool_nw.bat: 
   Batch script to launch CBS tool on Windows platforms. This batch references jars from SAP NetWeaver Developer Studio.

cbstool.bat: 
   Batch script to launch CBS tool on Windows platforms. This batch references jars from a separate directory. 
   This directory is created via batch file copyjars.bat first.

cbstool.sh: 
   Shell script to launch CBS tool on Linux/Unix platforms. The shell script references jars from a separate directory. 
   This directory is created via batch file copyjars.bat first.

jarlist_nw.txt:
   This file contains a list of required jar files. It is used in conjunction with batch file cbstool_nw.bat.

jarlist.txt: 
   This file contains a list of required jar files. It is used in conjunction with batch file cbstool.bat.

copyjars.bat: 
   Batch script to copy the required jar files from SAP NetWeaver Developer Studio into a separate directory.

readme.txt:
   This file

commandfile.txt: 
   A text file that contains a list of commands.



B)   Running CBS Tool on Windows Platforms

On Windows platforms the CBS Tool is launched by means of a batch file. 
The main purpose of the batch file is to construct the classpath for this Java application. 
In this context two cases are distinguished:


B1)   Jars underneath SAP NetWeaver Developer Studio installation folder are used

All jars that are required to run the CBS tool are located underneath <ROOTPATH>\eclipse. 
You have to set the environment variable SAPDEVSTUDIOHOME before you launch the CBS tool via batch file cbstool_nw.bat. 
It is very important that the environment variable SAPDEVSTUDIOHOME points to <ROOTPATH>\eclipse. 
If this environment variable is not set correctly the CBS tool startup will fail. 
Additionally you have to set the environment variable JAVA_HOME as well. 
JAVA_HOME must point to the installation folder of a Java SDK installation.

Assuming that the root installation path of SAP NetWeaver Developer Studio is C:Program Files\SAPJDT 
then SAPDEVSTUDIOHOME should be set to C:Program Files\SAPJDT\eclipse. 

To launch the CBS tool open a DOS prompt and change to the directory <ROOTPATH>\eclipse\tools\cbstool. 
Enter cbstool_nw.bat and press return. This will start the CBS tool in interactive mode. 
If you pass command line arguments to the batch file they will be forwarded to the CBS tool. 
If the CBS tool is launched with command line parameters it runs in batch mode.


B2)   Jars from a separate directory are used

There might be the need to run the CBS tool on a computer where no SAP NetWeaver Developer Studio has been installed. 
To copy the required files to the target computer proceed as described below. 
It is assumed in this context that SAP NetWeaver Developer Studio has been installed on a computer running on Windows operating system.

   1)	Open a DOS prompt and change to the directory <ROOTPATH>\eclipse\tools\cbstool. 
        Next execute the batch file copyjars.bat from that directory. 
        This will create two directories named cbstool_win and cbstool_unix. 
        In both directories there is a subdirectory lib that contains the required jars. 
        In directory cbstool_win there is a batch file cbstool.bat to launch the CBS tool. 
        Directory cbstool_unix contains the shell script cbstool.sh to launch the CBS tool.

   2)	Depending on the operating system of the target computer copy the required directory to the target
        i)  Windows: cbstool_win
        ii) Linux/Unix: cbstool_unix

On the target machine you have to set the environment variable CBSTOOLHOME before you launch the batch file cbstool.bat. 
The environment variable must point to the directory lib that contains the required jar files. 
Lets for example assume that directory lib is located in C:\cbstool_win\ then CBSTOOLHOME should be set to C:\cbstool_win\lib. 
In addition the environment variable JAVA_HOME, which must point to a Java SDK installation folder, has to be set as well.

Provided that this precondition is fulfilled open a DOS prompt and change to the directory where the batch file cbstool.bat is located. Enter cbstool.bat and press return. This will start the CBS tool in interactive mode. If you pass command line arguments to the batch file they will be forwarded to the CBS tool. If the CBS tool is launched with command line parameters it runs in batch mode.



C)   Running CBS Tool on Linux/Unix Platforms

At that time of first CBS tool shipment, the SAP NetWeaver Developer Studio installation is (was) not available for Linux/Unix platforms. In order to run the CBS tool on Linux/Unix platforms you have to copy the required directory cbstool_unix as described in section B2).

On the target machine you have to define the environment variable CBSTOOLHOME before you launch the shell script cbstool.sh. The environment variable must point to the directory lib that contains the required jar files. In addition the environment variable JAVA_HOME, which must point to a Java SDK installation folder, has to be set as well.

Provided that this precondition is fulfilled open a command shell and change to the directory where the shell script cbstool.sh is located. Enter cbstool.sh and press return. This will start the CBS tool in interactive mode. If you pass command line arguments to the shell script they will be forwarded to the CBS tool. If the CBS tool is launched with command line parameters it runs in batch mode.



D)   First Steps

Depending on the underlying operating system either start a DOS prompt or a shell and change to the directory where the corresponding batch file or shell script is located. 
Next start the corresponding batch file or shell script without any additional parameters. 


If the CBS command line tool has been launched successfully you should see this prompt:

:cbs>


Now you can enter CBS related commands. The command name must occur before the options and arguments. To get an overview of all commands available enter help and press return.

This lists all commands with a short description. 
To get more information on a specific command (especially which arguments it takes) enter help <command name> and press return.


Many commands require that a valid CBS connection exists. 
Without a valid CBS connection you will receive an error message like in the following example:

:cbs>bsstate -b rtest1

Invalid command usage:
There is no valid connection. Please connect first before executing this command.
Enter 'help <command name>' to get information on correct command us-age.

The syntax of the command was correct. 
But as no valid connection to CBS existed at this point in time the command could not be executed.  

To create a CBS connection via command connect you have to specify at least the CBS URL and a valid user/password combination. 
Next example shows the syntax of command connect:

:cbs>connect c http://server:port -u someuser -p rightpwd

In case that the specified user/password combination is not valid on the CBS you will get an error message as follows:

:cbs>connect c http://server:port -u someuser -p wrongpwd

Error while checking connection
User not authorized to log into build server. ( Service call excep-tion; nested exception is:        com.sap.engine.services.webservices.jaxrpc.exceptions.InvalidResponseCodeException: Invalid Response Code: (401) Unauthorized. )




The CBS command line tool runs in batch mode if command line parameters are passed when it is launched. 
In batch mode the tool processes all commands that have been passed and terminates afterwards.

Below an example is given for the Windows platform how the tool is launched in batch mode. 
Note that commands are separated by semicolon.

Example: 
C:\cbstool_win> cbstool_nw.bat connect -c http://server:port -u someuser -p rightpwd; bsstate -b mybuildspace

It is also possible to collect commands in a text file. 
Here you have to separate commands by semicolon as well. 
The text file can be passed via command line to the tool. 
Note that you have to put a @ character before the file name in order to distinguish a file name from a command

Example: 
C:\cbstool_win>cbstool @commandfile.txt

