Administrating Server via Command Line Utility

You can perform administrative tasks, such as users, projects, and permissions management, using a command line utility. The utility is stored in <Teamwork Server installation directory>\bin. It is called teamwork_console.exe for Windows and teamwork_console for Unix and Unix-like operating systems.

The ability to access the server administrative functions via the command line utility facilitates the scriptable management of Teamwork Server. This enables automation of routine administrative tasks, such as permission management. Single commands can be given through the command line utility parameters. Multiple commands can be given in bulk through the input stream. Command results are provided through exit status codes, enabling conditional script execution.

To perform administrative tasks using the command line utility


  1. Start Teamwork Server.
  2. Open the command line interface.
  3. At the command line, type the following command: 

    cd <Teamwork Server installation directory>\bin

    cd C:\Downloads\MagicDraw_180_sp2_teamwork_server_no_install\bin

  4. At the command line, type the following command: 

    teamwork_console.exe -u username -p password servername

    teamwork_console.exe -u Administrator -p Administrator localhost

You are successfully logged into the server and can now perform server administration tasks. 

The following table includes the command line utility commands for performing administrative tasks and their brief descriptions.

CommandDescription
mkuserCreates an external user.

rmuser

Deletes the given user.
lsuserLists all users or tests if the given user exists.
mkprojCreates an empty project.
rmprojDeletes the given project.
lsprojLists all projects or tests if the given projects exist.
stpermSets the specified permission of the specified user on a given project.
clpermClears the specified permission of the specified user on a given project.
lspermLists permissions of the specified user on a given project.


For detailed command descriptions, refer to the help section, printed after typing any of the following commands at the command line:

  • teamwork_console.exe --help
  • teamwork_console.exe -h

Any of the commands in the preceding table can be typed at the command line immediately after the servername parameter.

Example: teamwork_console.exe -u Administrator -p Administrator localhost lsuser

If your Teamwork Server runs on Linux or another Unix-based operating system, you can avoid typing a long command every time by using the following command once:

alias tc="./teamwork_console -u username -p password servername"

In the sequel, you can type “tc” instead of “teamwork_console -u username -p password servername”, for example, “tc lsuser”.

Giving commands on the input stream

The commands for performing supported administrative tasks can be given on the input stream. This is indicated by specifying the “-” parameter immediately after the servername parameter.

Example: teamwork_console.exe -u Administrator -p Administrator localhost -

In this case the command line utility connects to the specified server with the given credentials, performs the commands and exits.

Example:

This is a shell script for creating a project and assigning users to it:

#!/bin/bash
#shorthand
TC='/MagicDraw_TeamworkServer_installation_directory/bin/ teamwork_console -u Administrator -p Administrator localhost' 
#create a blank project in a category, store output in a variable, 
#exit on fail
PID=$( $TC mkproj "TestPr" "Training Material and Demos" ) || { echo "Failed to create project" >&2; exit 1; } 
#pump multiple set permission commands into the teamwork console$TC - << EOF
stperm user1 RD $PID 
stperm user1 RR $PID 
stperm user1 WR $PID 
EOF