Difference between revisions of "Command-Line Options"

From BaseX Documentation
Jump to navigation Jump to search
Line 1: Line 1:
 
This article is part of the [[Getting Started]] Guide.
 
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]].
 
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==
 
==BaseX GUI==
Line 10: Line 8:
 
</pre>
 
</pre>
  
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.
+
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. XQuery files are opened in the XQuery editor.
  
 
==BaseX Standalone==
 
==BaseX Standalone==
Line 23: Line 21:
 
<pre>
 
<pre>
 
$ basex -h
 
$ basex -h
Usage: basex [-bdiosuvVwxz] [-cq] [file]
+
BaseX [Standalone]
 +
Usage: basex [-bcdioqsuvVwxz] [file]
 
   [file]      Execute XQuery file
 
   [file]      Execute XQuery file
 
   -b<pars>    Bind external XQuery variables
 
   -b<pars>    Bind external XQuery variables
Line 46: Line 45:
 
! Description
 
! Description
 
! Option
 
! Option
! width='165' | Examples
+
! Examples
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|[file]}}
 
| {{Mono|[file]}}
| Execute the specified XQuery file.
+
| Executes the specified XQuery file.
 
|
 
|
 
|- valign="top"
 
|- valign="top"
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-b&lt;pars&gt;}}
 
| {{Mono|-b&lt;pars&gt;}}
| 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.
+
| 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>
 
| <code>[[Options#BINDINGS|BINDINGS]]</code>
| <code>-bv=example<br />-q"declare variable $v external; $v"</code>
+
| <ul><li><code>-b$v=example -q$v</code></li><li><code>-b{URL}ln=value<br/>-q"declare namespace ns='URL'; $ns:ln"</code></li></ul>
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-c&lt;cmd&gt;}}
 
| {{Mono|-c&lt;cmd&gt;}}
| 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.
+
| Launches database commands and skips the interactive mode. Several commands can be separated by semicolons.
 
|
 
|
 
| {{Mono|-c"list;info"}}
 
| {{Mono|-c"list;info"}}
Line 79: Line 78:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-q&lt;expr&gt;}}
 
| {{Mono|-q&lt;expr&gt;}}
| Executes the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
+
| Executes the specified string as XQuery expression.
 
|
 
|
 
| {{Mono|-q"doc('input')//head"}}
 
| {{Mono|-q"doc('input')//head"}}
Line 118: Line 117:
 
|
 
|
 
|}
 
|}
 +
 +
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==
 
==BaseX Server==
Line 130: Line 131:
 
<pre>
 
<pre>
 
$ basexserver -h
 
$ basexserver -h
Usage: BaseXServer [-deipSz] [-c] [stop]
+
BaseX [Server]
   stop     Stop running server
+
Usage: basexserver [-cdeipSz] [stop]
   -c<cmd> Execute initial database command(s)
+
   stop     Stop running server
   -d       Activate debugging mode
+
   -c<cmd>   Execute initial database command(s)
   -e<num> Set event port
+
   -d       Activate debugging mode
   -i       Enter interactive mode
+
   -e<num>   Set event port
   -p<num> Set server port
+
   -i       Enter interactive mode
   -S       Start as service
+
   -p<num>   Set server port
   -z       Suppress logging
+
   -S       Start as service
 +
   -z       Suppress logging
 
</pre>
 
</pre>
  
Line 157: Line 159:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-c&lt;cmd&gt;}}
 
| {{Mono|-c&lt;cmd&gt;}}
| 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.
+
| Launches database commands before the server itself is started. Several commands can be separated by semicolons.
 
|
 
|
 
|
 
|
Line 187: Line 189:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-S}}
 
| {{Mono|-S}}
| Starts the server as service (i.e., in the background). {{Mark|Modified in Version 7.0.1}}
+
| Starts the server as service (i.e., in the background).
 
|
 
|
 
|  
 
|  
Line 196: Line 198:
 
|  
 
|  
 
|}
 
|}
 +
 +
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==
 
==BaseX Client==
Line 214: Line 218:
 
<pre>
 
<pre>
 
$ basexclient -h
 
$ basexclient -h
Usage: basexclient [-bdinopPsUvVwxz] [-cq] [file]
+
BaseX [Client]
 +
Usage: basexclient [-bcdinopPqsUvVwxz] [file]
 
   [file]      Execute XQuery file
 
   [file]      Execute XQuery file
 
   -b<pars>    Bind external XQuery variables
 
   -b<pars>    Bind external XQuery variables
Line 244: Line 249:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|[file]}}
 
| {{Mono|[file]}}
| Execute the specified XQuery file.
+
| Executes the specified XQuery file.
 
|
 
|
 
|
 
|
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-b&lt;pars&gt;}}
 
| {{Mono|-b&lt;pars&gt;}}
| 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.
+
| 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>
 
| <code>[[Options#BINDINGS|BINDINGS]]</code>
 
|
 
|
| <code>-bv=example<br />-q"declare variable $v external; $v"</code>
+
| <ul><li><code>-b$v=example -q$v</code></li><li><code>-b{URL}ln=value<br/>-q"declare namespace ns='URL'; $ns:ln"</code></li></ul>
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-c&lt;cmd&gt;}}
 
| {{Mono|-c&lt;cmd&gt;}}
| 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.
+
| Launches database commands and skips the interactive mode. Several commands can be separated by semicolons.
 
|
 
|
 
|
 
|
Line 297: Line 302:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-q&lt;expr&gt;}}
 
| {{Mono|-q&lt;expr&gt;}}
| Executes the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
+
| Executes the specified string as XQuery expression.
 
|
 
|
 
|
 
|
Line 344: Line 349:
 
|
 
|
 
|}
 
|}
 +
 +
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==
 
==BaseX HTTP Server==
  
;Launch the HTTP server (introduced with {{Version|7.0}}):
+
;Launch the HTTP server:
 
<pre>
 
<pre>
 
$ basexhttp
 
$ basexhttp
Line 360: Line 367:
 
$ basexhttp -h
 
$ basexhttp -h
 
BaseX [HTTP]
 
BaseX [HTTP]
Usage: basexhttp [-cdehlnpPRsSUWz] [stop]
+
Usage: basexhttp [-dehlnpPRUWz] [stop]
   stop     Stop running server
+
   stop       Stop running server
   -c       Start in client mode
+
   -c         Start in client mode
   -d       Activate debugging mode
+
   -d         Activate debugging mode
   -e<num>   Set event port
+
   -e<num>   Set event port
   -h<num>   Set port of HTTP server
+
   -h<num>   Set port of HTTP server
   -l       Start in local mode
+
   -l         Start in local mode
   -n<name> Set name of database server
+
   -n<name>   Set host name of database server
   -p<num>   Set port of database server
+
   -p<num>   Set port of database server
   -P<pass> Specify user password
+
   -P<pass>   Specify user password
   -R       Deactivate REST service
+
   -R         Deactivate REST service
   -s       Specify port to stop HTTP server
+
   -s         Specify port to stop HTTP server
   -S       Start as service
+
   -S         Start as service
   -U<name> Specify user name
+
   -U<name>   Specify user name
   -W       Deactivate WebDAV service
+
   -W         Deactivate WebDAV service
   -z       Suppress logging
+
   -z         Suppress logging
 
</pre>
 
</pre>
  
Line 395: Line 402:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-c}}
 
| {{Mono|-c}}
| Starts the server in ''client mode'', and sends all commands to a database server instance. {{Mark|Introduced with Version 7.0.1}}
+
| Starts the server in ''client mode'', and sends all commands to a database server instance.
 
|
 
|
 
|
 
|
Line 449: Line 456:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-s&lt;num&gt;}}
 
| {{Mono|-s&lt;num&gt;}}
| Specifies the port that will be used to stop the HTTP server. {{Mark|Introduced with Version 7.0.1}}
+
| Specifies the port that will be used to stop the HTTP server.
 
| <code>[[Options#STOPPORT|STOPPORT]]</code>
 
| <code>[[Options#STOPPORT|STOPPORT]]</code>
 
|
 
|
Line 455: Line 462:
 
|- valign="top"
 
|- valign="top"
 
| {{Mono|-S}}
 
| {{Mono|-S}}
| Starts the server as service (i.e., in the background). {{Mark|Introduced with Version 7.0.1}}
+
| Starts the server as service (i.e., in the background).
 
|
 
|
 
|  
 
|  
Line 481: Line 488:
 
* {{Mono|org.basex.user}}: user name for opening new sessions
 
* {{Mono|org.basex.user}}: user name for opening new sessions
 
* {{Mono|org.basex.password}}: user password 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.
+
* {{Mono|org.basex.mode}}: 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]]
 
[[Category:Beginner]]

Revision as of 06:41, 7 February 2012

This article is part of the Getting Started Guide. It gives some more details on the command-line options of all BaseX start scripts.

BaseX GUI

Launch the GUI
$ basexgui [file]

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. XQuery files are 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
BaseX [Standalone]
Usage: basex [-bcdioqsuvVwxz] [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] Executes 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. If a variable uses a namespace different to the default namespace, it can be specified with the Clark Notation or Expanded QName Notation. BINDINGS
  • -b$v=example -q$v
  • -b{URL}ln=value
    -q"declare namespace ns='URL'; $ns:ln"
-c<cmd> Launches database commands and skips the interactive mode. 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. -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

Since Version 7.1, multiple query files and -c/-i/-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 (-) as argument.

BaseX Server

Launch the server
$ basexserver
BaseX [Server]
Server was started.

Available command-line flags can be listed with -h:

$ basexserver -h
BaseX [Server]
Usage: basexserver [-cdeipSz] [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 flags have the following meaning (equivalent database options are shown in the table as well):

Flag Description Option Default Examples
stop Stops an existing server instance and quits.
-c<cmd> Launches database commands before the server itself is started. 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).
-z Does not generate any log files.

Multiple -c and -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 (-) as argument.

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
BaseX [Client]
Usage: basexclient [-bcdinopPqsUvVwxz] [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] Executes 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. If a variable uses a namespace different to the default namespace, it can be specified with the Clark Notation or Expanded QName Notation. BINDINGS
  • -b$v=example -q$v
  • -b{URL}ln=value
    -q"declare namespace ns='URL'; $ns:ln"
-c<cmd> Launches database commands and skips the interactive mode. 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"
-n<name> Specifies the host name on which the server is running. HOST localhost -nserver.basex.org
-o<file> All command and query output is written to the specified file.
-p<num> Specifies the port on which the server is running. PORT 1984 -p9999
-P<pass> Specifies the user password. If this flag is omitted, the password will be requested on command line. Warning: when the password is specified via this flag, it may be visible to others. -Uadmin -Padmin
-q<expr> Executes the specified string as XQuery expression. -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<name> Specifies the user name. If this flag is omitted, the user name will be requested on command line. -Uadmin
-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

Multiple query files and -c/-i/-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 (-) as argument.

BaseX HTTP Server

Launch the HTTP server
$ 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 flags can be listed with -h:

$ basexhttp -h
BaseX [HTTP]
Usage: basexhttp [-dehlnpPRUWz] [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

The flags have the following meaning (equivalent database options are shown in the table as well):

Flag Description Option Default Examples
stop Stops 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.
-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
-h<num> Specifies the port on which the HTTP server will be addressable. This port is e.g. specified in the HTTP URLs. HTTPPORT 8984 -h9999
-l Starts the server in local mode, and executes all commands in the embedded database context.
-n<name> Specifies the host name on which the server is running. HOST localhost -nserver.basex.org
-p<num> Specifies the port on which the BaseX Server will be addressable. SERVERPORT 1984 -p9998
-P<pass> Specifies the user password, which will be used by the HTTP services to open a new session. If this flag is omitted, the password will be requested on command line. 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> Specifies the port that will be used to stop the HTTP server. STOPPORT
-S Starts the server as service (i.e., in the background).
-U<name> Specifies the user name, which will be used by the HTTP services for opening a new session. If this flag is omitted, the password will be requested on command line. admin -Uadmin
-W Deactivates the WebDAV service.
-z Does not generate any log files.

Some options can also be triggered by setting the following system properties:

  • org.basex.user: user name for opening new sessions
  • org.basex.password: user password for opening new sessions
  • org.basex.mode: by default, the HTTP server also starts an instance of the database server. If the mode is set to local, an embedded database context is used for executing commands. If the mode is set to client, all commands are sent to an existing database server instance.