Command-Line Options
This article is part of the Getting Started Guide. It gives some more details on the command-line options of all BaseX start scripts:
A preview page contains all startup options offered by the latest stable snapshot.
BaseX GUI
- Launch the GUI
$ basexgui [file]
XML and XQuery files can be passed on as parameters. If an XML file is specified, a database instance is created from this file, or an existing database is opened. If an XQuery expression is passed on, it is opened in the XQuery editor.
BaseX Standalone
- Launch the console mode
$ basex BaseX [Standalone] Try "help" to get more information. > _
Available command-line flags can be listed with -h
:
$ basex -h Usage: basex [-bdiosuvVwxz] [-cq] [file] [file] Execute XQuery file -b<pars> Bind external XQuery variables -c<cmd> Execute database command(s) -d Activate debugging mode -i<input> Open initial file or database -o<file> Write output to file -q<expr> Execute XQuery expression -s<pars> Set serialization parameter(s) -u Write updates back to original files -v/V Show (all) process info -w Preserve whitespaces from input files -x Show query execution plan -z Skip output of results
The meaning of all flags is listed in the following. If an equivalent database option exists (which can be specified via the SET command), it is listed as well:
Flag | Description | Option | Examples |
---|---|---|---|
[file]
|
Execute the specified XQuery file. | ||
-b<pars>
|
Binds external variables to XQuery expressions. This flag may be specified multiple times. Variables names and their values are delimited by equality signs (= ). The names may be optionally prefixed with dollar signs. The BINDINGS option serves the same purpose.
|
BINDINGS
|
-bv=example
|
-c<cmd>
|
Launches database commands and skips the interactive mode. The flag should be placed last, as all remaining characters are interpreted as commands. Several commands can be separated by semicolons. | -c"list;info"
| |
-d
|
Turns on the debugging mode. Debugging information is output to standard error. | DEBUG
|
|
-i<input>
|
Opens a database or XML document specified by the argument. The opened input may be further processed by an XQuery expression. | -iitems.xml -q"//item"
| |
-o<file>
|
All command and query output is written to the specified file. | -o output.txt
| |
-q<expr>
|
Executes the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery. | -q"doc('input')//head"
| |
-s<pars>
|
Specifies parameters for serializing XQuery results; see Serialization for more details. This flag may be specified multiple times. Key and values are separated by the equality sign (= ).
|
SERIALIZER
|
-smethod=text
|
-u
|
Modifies original files after evaluating XQuery Update expressions. | WRITEBACK
|
|
-v
|
Prints process and timing information to the standard output. | ||
-V
|
Prints detailed query information to the standard output, including details on the compilation and profiling steps. | QUERYINFO
|
|
-w
|
By default, whitespaces around text nodes are chopped when a database is created. This flag can be specified to preserve whitespaces. | CHOP
|
|
-x
|
This flags turn on the output of the query execution plan, formatted in XML. | XMLPLAN
|
|
-z
|
Skips the serialization of XQuery results. This flag is useful if the query is profiled or analyzed. | SERIALIZE
|
BaseX Server
- Launch the server
$ basexserver BaseX [Server] Server was started.
Available command-line options can be listed with the -h
flag:
$ basexserver -h Usage: BaseXServer [-deipSz] [-c] [stop] stop Stop running server -c<cmd> Execute initial database command(s) -d Activate debugging mode -e<num> Set event port -i Enter interactive mode -p<num> Set server port -S Start as service -z Suppress logging
The options have the following meaning (as above, equivalent database options have been included in the table):
Flag | Description | Option | Default | Examples |
---|---|---|---|---|
stop
|
Stops an existing server instance and quits. | |||
-c<cmd>
|
Launches database commands before the server itself is started. The flag should be placed last, as all remaining characters are interpreted as commands. Several commands can be separated by semicolons. | -c"open database;info"
| ||
-d
|
Turns on the debugging mode. Debugging information is output to standard error. | DEBUG
|
||
-e<num>
|
Specifies the port on which the server will send events to clients. | EVENTPORT
|
1985
|
-e9998
|
-i
|
Starts the interactive console mode, which can be used to enter database commands. This mode is similar to the default standalone and client mode. | |||
-p<num>
|
Specifies the port on which the server will be addressable. | PORT
|
1984
|
-p9999
|
-S
|
Starts the server as service (i.e., in the background). Template:Mark | |||
-z
|
Does not generate any log files. |
BaseX Client
- Launch the console mode communicating with the server
The user name and password will be requested. The default user/password combination is admin/admin:
$ basexclient Username: admin Password: ***** BaseX [Client] Try "help" to get more information. > _
Available command-line flags can be listed with -h
:
$ basexclient -h Usage: basexclient [-bdinopPsUvVwxz] [-cq] [file] [file] Execute XQuery file -b<pars> Bind external XQuery variables -c<cmd> Execute database command(s) -d Activate debugging mode -i<input> Open initial file or database -n<name> Set server (host) name -o<file> Write output to file -p<num> Set server port -P<pass> Specify user password -q<expr> Execute XQuery expression -s<pars> Set serialization parameter(s) -U<name> Specify user name -v/V Show (all) process info -w Preserve whitespaces from input files -x Show query execution plan -z Skip output of results
The flags have the following meaning (equivalent database options are shown in the table as well):
Flag | Description | Option | Default | Examples |
---|---|---|---|---|
[file]
|
Execute the specified XQuery file. | |||
-b<pars>
|
Bind external variables to XQuery expressions. This flag may be specified multiple times; key/value pairs are separated by equality signs (= ).
|
-bv=example
| ||
-c<cmd>
|
Launch database commands and skip interactive mode. The flag should be placed last, all remaining characters are interpreted as commands. Several commands can be separated by semicolons. | -c"list;info"
| ||
-d
|
Turn on debugging. Debugging information is output to standard error. | |||
-i<input>
|
Open a database or XML document specified by the argument. The opened input may be further processed by an XQuery expression. | -iitems.xml -q"//item"
| ||
-n<name>
|
Specify the server name on which the server is running. | localhost
|
-nserver.basex.org
| |
-o<file>
|
Command and query output is written to the specified file. | |||
-p<num>
|
Specify the port on which the server is running. | 1984
|
-p9999
| |
-P<pass>
|
Specify the user password. Warning: when the password is specified on command-line, it may be visible to others. | -Uadmin -Padmin
| ||
-q<expr>
|
Execute the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery. | -q"doc('input')//head"
| ||
-s<pars>
|
Specify parameters for serializing XQuery results; see Serialization for more details. This flag may be specified multiple times; key/value pairs are separated by equality signs (= ).
|
-smethod=text
| ||
-U<name>
|
Specify the user name. | -Uadmin
| ||
-v
|
Process information is written to standard output (STDOUT ).
|
|||
-V
|
Detailed query information is written to standard output, including compilation and profiling steps. | |||
-w
|
By default, whitespaces around text nodes are chopped when a database is created. This flag can be specified to suppress chopping. | |||
-x
|
This flags turn on the output of the query execution plan, formatted in XML. | |||
-z
|
Skip the serialization of XQuery results. This flag is useful for analyzing query plans. |
BaseX HTTP Server
- Launch the HTTP server (introduced with Version 7.0)
$ basexhttp BaseX [Server] Server was started. 2011-01-02 03:04:05.600:INFO::Logging to STDERR via org.mortbay.log.StdErrLog 2011-01-02 03:04:05.700:INFO::jetty-6.1.26 2011-01-02 03:04:05.800:INFO::Started SocketConnector@0.0.0.0:8984
Available command-line options can be listed with the -h
flag:
$ basexhttp -h BaseX [HTTP] Usage: basexhttp [-cdehlnpPRsSUWz] [stop] stop Stop running server -c Start in client mode -d Activate debugging mode -e<num> Set event port -h<num> Set port of HTTP server -l Start in local mode -n<name> Set name of database server -p<num> Set port of database server -P<pass> Specify user password -R Deactivate REST service -s Specify port to stop HTTP server -S Start as service -U<name> Specify user name -W Deactivate WebDAV service -z Suppress logging
The options have the following meaning:
Flag | Description | Default | Examples |
---|---|---|---|
stop
|
Stop a running HTTP server. By default, the database server will be stopped as well, unless one of the flags -c or -l is specified.
|
||
-c
|
Starts the server in client mode, and sends all commands to a database server instance. Template:Mark | ||
-d
|
Turn on debugging. Debugging information is output to standard error. | ||
-e<num>
|
Specify the port on which the server will send events to clients. | 1985
|
-e9998
|
-h<num>
|
The port on which the HTTP server will be addressable. This port is e.g. specified in the HTTP URLs. | 8984
|
-h9999
|
-l
|
Starts the server in local mode, and executes all commands in the embedded database context. | ||
-n<name>
|
The server name on which the server is running. | localhost
|
-nserver.basex.org
|
-p<num>
|
The port on which the BaseX Server will be addressable. | 1984
|
-p9998
|
-P<pass>
|
The user password, which will be used by the HTTP services for opening a new session. Warning: when the password is specified on command-line, it may be visible to others. | admin
|
-Uadmin -Padmin
|
-R
|
Deactivates the REST service. | ||
-s<num>
|
The port that will be used to stop the HTTP server. Template:Mark | ||
-S
|
Starts the server as service (i.e., in the background). Template:Mark | ||
-U<name>
|
The user name, which will be used by the HTTP services for opening a new session. | admin
|
-Uadmin
|
-W
|
Deactivates the WebDAV service. | ||
-z
|
Do not generate log files. |
Some options can also be triggered by setting the following system properties:
org.basex.user
: user name for opening new sessionsorg.basex.password
: user password for opening new sessionsorg.basex.mode
(Version 7.0.1): by default, the HTTP server also starts an instance of the database server. If the mode is set tolocal
, an embedded database context is used for executing commands. If the mode is set toclient
, all commands are sent to an existing database server instance.