15. Bridge Command Line Interface (CLI)¶
The GeoCat Bridge Command Line Interface (CLI) allows GeoCat Bridge users to automate the publishing process, by setting up scheduled tasks to publish ArcGIS map documents to a map server and publish the associated metadata to a catalog server. In combination with scheduled tasks Bridge can ensure that the data and metadata on the server is kept up to date.
Supported servers for the Bridge CLI are:
- MapServer
- GeoServer
- GeoNetwork
- CSW (Catalog Server for the Web) servers
For supported versions see Server Requirements.
The GeoCat CLI executable “bridge.exe” can be found in the installation directory of GeoCat Bridge. Typically in C:\Program Files (x86)\GeoCat\Bridge 2
(on 64 bits systems) or C:\Program Files\GeoCat\Bridge 2
(on 32 bits systems).
A Bridge Premium license is required for the Bridge CLI.
Input¶
The Bridge CLI takes either an ESRI layer (.lyr) or an ESRI map document (.mxd) as input. The layers in the input file will be published to the selected map server.
When publishing to GeoServer and using Bridge in the Managed Workspaces (see ManagedWorkspacesMode) mode or when publishing to MapServer, Bridge will name the GeoServer workspace or MapServer mapfile like this:
Input | Workspace or Mapfile name |
---|---|
Layer file | Filename of lyr file (without extension) |
MXD | Filename of mxd file (without extension) |
By default when publishing to GeoServer Bridge will publish the layers in the selected workspace of the selected GeoServer configuration.
Logging¶
The Bridge CLI logs its output to a separate log file which can be found in the local data directory of the current user: C:\Users\<USER>\AppData\Local\GeoCat\Bridge 2\Bridge-cli_<DATE>.log
. Log files older than 7 days are automatically removed from the system.
The log level can be changed by editing the NLog-CLI.config file in the Bridge installation directory. Change the minlevel value of the following line to change the log level:
allowed values= Debug, Info, Warning, Error
<logger name="*" minlevel="Error" writeTo="file" />
Exit-code¶
On successful completion the Bridge CLI exits with code 0. On failure the Bridge CLI exits with code 1.
Usage¶
You can either add the Bridge installation directory to your path or execute the CLI from the Bridge installation directory. Call bridge help
from the Bridge installation directory to display help content on the Bridge CLI. This will list the available commands:
GeoCat Bridge CLI 2.1.0.0
Copyright c GeoCat 2010-2016
remove Remove the layers or metadata records from a server.
publish Publish your layers to a map server or catalog server.
list List servers and layers from mxd or lyr file.
To view help for options list and publish type 'help list' or 'help publish'
List command¶
Call bridge help list
to show the help contents for the list command:
GeoCat Bridge CLI 2.2.0.0
Copyright c GeoCat 2010-2017
-f, --file [string] Path to mxd or lyr file to list layers
-d, --dataservers [flag] List dataservers to publish to.
-c, --catalogservers [flag] List catalogservers to publish to.
Examples¶
List the available dataservers by calling either:
bridge list -d
bridge list --dataservers
List the available catalogservers by calling either:
bridge list -c
bridge list --catalogservers
List the layers available for publishing in an mxd or lyr file by calling either:
bridge list -l C:\path\to\mxd\file.mxd
bridge list --layers C:\path\to\mxd\file.mxd
Publish command¶
Call bridge help publish
to show the help contents for the publish command:
GeoCat Bridge CLI 2.3.0.0
Copyright c GeoCat 2010-2017
-f, --file Required. [string] Path to mxd or lyr file to publish.
-d, --dataserver [string] ID of dataserver to publish to.
-c, --catalogserver [string] ID of catalogserver to publish to.
-l, --layers [string] Specify layers to publish, separated by a
colon.
-m, --modes [string] Specify what to publish, available values are
data and symbology. By default data and symbology are
published when a dataserver is specified.
-a, --all [flag] Publish all layers, in case layers are turned
off in map document. In ManagedWorkspace mode all
layers are published by default.
-v, --verbose [flag] Verbose mode, output logging to console.
-o, --logfile [string] Path to optional log file, when specified
Bridge logs to default log file and the optional log
file
-x, --offline [String] Set destination directory for offline
publication. Directory needs to exist.
Examples¶
Publish an mxd to server with ID MS_1
:
bridge publish -f C:\path\to\mxd\file.mxd -d MS_1
Publish an mxd to server with ID MS_1
, but only layers roads and sites:
bridge publish -f C:\path\to\mxd\file.mxd -d MS_1 -l roads:sites
Publish an mxd to server with ID MS_1
, but only publish data (no symbology):
bridge publish -f C:\path\to\mxd\file.mxd -d MS_1 -m data
Publish an mxd to server with ID MS_1
but only layers roads and sites:
bridge publish -f C:\path\to\mxd\file.mxd -d MS_1 -l roads:sites
Publish an mxd to server with ID MS_1
and output log to command prompt:
bridge publish -f C:\path\to\mxd\file.mxd -d MS_1 -v
Publish an mxd to server with ID “GS_1” and output log to another log file:
bridge publish -f C:\path\to\mxd\file.mxd -d GS_1 -o C:\path\to\logfile.log
Publish an mxd to dataserver with ID “GS_1” and to catalogserver with ID “GN_1”:
bridge publish -f C:\path\to\mxd\file.mxd -d GS_1 -c GN_1 -x C:\offline_publication
Publish an mxd offline to directory C:offline_publication, metadata, data and symbology files are published to the specified offline directory. It is required to specify an existing server connection, to indicate the type of offline export (GeoServer, MapServer, GeoNetwork, CSW).
Remove command¶
Call bridge help remove
to show the help contents for the publish command:
GeoCat Bridge CLI 2.2.0.0
Copyright c GeoCat 2010-2017
-f, --file Required. [string] Path to mxd or lyr file to remove.
-d, --dataserver [string] ID of dataserver to remove layers from.
-c, --catalogserver [string] ID of catalogserver to remove metadata from.
-o, --logfile [string] Path to optional log file, when specified
Bridge logs to default log file and the optional log
file
-v, --verbose [flag] Verbose mode, output logging to console.
Examples¶
Remove the layers of an mxd from a dataserver with ID “MS_1”:
bridge remove -f C:\path\to\mxd\file.mxd -d MS_1
Remove the layers of an mxd from a dataserver with ID “GS_1” and from a catalogserver with ID “GN_1”
bridge remove -f C:\path\to\mxd\file.mxd -d GS_1 -c GN_1
Remove the layers of an mxd from a dataserver with ID “MS_1” and output log to another log file:
bridge remove -f C:\path\to\mxd\file.mxd -d MS_1 -o C:\path\to\logfile.log