This article is part of the [[Getting Started]] Guide.
It gives some more details on the command-line options of all BaseX [[Start Scripts|start scripts]].
A [[Startup Options (Snapshot)|preview page]] contains all startup options offered by the [http://files.basex.org/releases/latest/ latest stable snapshot].
==BaseX GUI==
</pre>
One or more 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 files are opened in the XQuery editor.
==BaseX Standalone==
<pre>
$ basex -h
BaseX [Standalone]Usage: basex [-bdiosuvVwxz] [-cqbcdioqsuvVwxz] [file]
[file] Execute XQuery file
-b<pars> Bind external XQuery variables
! Description
! Option
! width='165' | Examples
|- valign="top"
| {{Mono|[file]}}
| Execute Executes the specified XQuery file.
|
|- valign="top"
|- valign="top"
| {{Mono|-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 (<code>=</code>). The names may be optionally prefixed with dollar signs. If a variable uses a namespace different to the default namespace, it can be specified with the [http://www.jclark.com/xml/xmlns.htm Clark Notation] or [http://www.w3.org/TR/xquery-30/#id-basics Expanded QName Notation].
| <code>[[Options#BINDINGS|BINDINGS]]</code>
| <ul><li><code>-bvb$v=example-q$v</code></li><li><code>-b{URL}ln=value<br />-q"declare variable $v externalnamespace ns='URL'; $vns:ln"</code></li></ul>
|- valign="top"
| {{Mono|-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.
|
| {{Mono|-c"list;info"}}
|- valign="top"
| {{Mono|-q<expr>}}
| Executes the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
|
| {{Mono|-q"doc('input')//head"}}
|
|}
Since {{Version|7.1}}, multiple query files and {{Mono|-c}}/{{Mono|-i}}/{{Mono|-q}} flags can be specified. All other options will be set before any other operation takes place. The specified inputs, query files, queries and commands will be subsequently evaluated after that in the given order. The standard input can be parsed by specifying a single dash ({{mono|-}}) as argument.
==BaseX Server==
<pre>
$ basexserver -h
BaseX [Server]Usage: BaseXServer [-deipSz] basexserver [-ccdeipSz] [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
</pre>
|- valign="top"
| {{Mono|-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.
|
|
|- valign="top"
| {{Mono|-S}}
| Starts the server as service (i.e., in the background). {{Mark|Modified in Version 7.0.1}}
|
|
|
|}
Multiple {{Mono|-c}} and {{Mono|-i}} flags can be specified. All other options will be set before any other operation takes place. The specified inputs, query files, queries and commands will be subsequently evaluated after that in the given order. The standard input can be parsed by specifying a single dash ({{mono|-}}) as argument.
==BaseX Client==
<pre>
$ basexclient -h
BaseX [Client]Usage: basexclient [-bdinopPsUvVwxz] [-cqbcdinopPqsUvVwxz] [file]
[file] Execute XQuery file
-b<pars> Bind external XQuery variables
|- valign="top"
| {{Mono|[file]}}
| Execute Executes the specified XQuery file.
|
|
|- valign="top"
| {{Mono|-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 (<code>=</code>). The names may be optionally prefixed with dollar signs. If a variable uses a namespace different to the default namespace, it can be specified with the [http://www.jclark.com/xml/xmlns.htm Clark Notation] or [http://www.w3.org/TR/xquery-30/#id-basics Expanded QName Notation].
| <code>[[Options#BINDINGS|BINDINGS]]</code>
|
| <ul><li><code>-bvb$v=example-q$v</code></li><li><code>-b{URL}ln=value<br />-q"declare variable $v externalnamespace ns='URL'; $vns:ln"</code></li></ul>
|- valign="top"
| {{Mono|-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.
|
|
|- valign="top"
| {{Mono|-q<expr>}}
| Executes the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
|
|
|
|}
Multiple query files and {{Mono|-c}}/{{Mono|-i}}/{{Mono|-q}} flags can be specified. All other options will be set before any other operation takes place. The specified inputs, query files, queries and commands will be subsequently evaluated after that in the given order. The standard input can be parsed by specifying a single dash ({{mono|-}}) as argument.
==BaseX HTTP Server==
;Launch the HTTP server (introduced with {{Version|7.0}}):
<pre>
$ basexhttp
$ basexhttp -h
BaseX [HTTP]
Usage: basexhttp [-cdehlnpPRsSUWzdehlnpPRUWz] [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 host 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
</pre>
|- valign="top"
| {{Mono|-c}}
| Starts the server in ''client mode'', and sends all commands to a database server instance. {{Mark|Introduced with Version 7.0.1}}
|
|
|- valign="top"
| {{Mono|-s<num>}}
| Specifies the port that will be used to stop the HTTP server. {{Mark|Introduced with Version 7.0.1}}
| <code>[[Options#STOPPORT|STOPPORT]]</code>
|
|- valign="top"
| {{Mono|-S}}
| Starts the server as service (i.e., in the background). {{Mark|Introduced with Version 7.0.1}}
|
|
* {{Mono|org.basex.user}}: user name for opening new sessions
* {{Mono|org.basex.password}}: user password for opening new sessions
* {{Mono|org.basex.mode}} ({{Version|7.0.1}}): by default, the HTTP server also starts an instance of the database server. If the mode is set to {{Mono|local}}, an embedded database context is used for executing commands. If the mode is set to {{Mono|client}}, all commands are sent to an existing database server instance.
[[Category:Beginner]]