Nuxeo Server

Nuxeo Shell Batch Mode

Updated: September 22, 2017 Page Information Edit on GitHub

This page is scheduled for review and update. Check back soon for updated content!

As said in the Overview section there are three modes to execute batch commands:

  1. Run commands from a file
  2. Run commands from standard input.
  3. Run commands specified on the command line - this is a convenient way to run a short list of commands.

Running Commands From a File

To run commands from a file you should use the -f parameter to specify a file containing commands when launching Nuxeo Shell.

Example:

java -cp nuxeo-shell.jar org.nuxeo.shell.Main -f my_batch_file

Where my_batch_file is a file containing the commands to execute - each command on one line. Empty lines and lines begining with # are ignored. The # character can be use to add comments to a batch file.

Here is an example of a batch file:

# connect to local server using the Administrator account.
connect -u Administrator -p Administrator http://localhost:8080/nuxeo/site/automation

# we are now in the repository root. Go to /default-domain/workspaces
cd /default-domain/workspaces

# list the content of the workspaces root - as document UIDs
ls -uid

If you want to span a command on multiple lines (you may want this for improved readability in case of long commands) you can end the line with a character (make sure you don't have a space after ). In that case the command will continue on the next line, and so on until no more line ending is found or the end of file is reached.

Example:

# connect to local server using the Administrator account.
connect -u Administrator -p Administrator http://localhost:8080/nuxeo/site/automation

# get all workspaces in the repository
query "SELECT * FROM Document WHERE ecm:primaryType='Workspace' \
      ORDER BY dc:title DESC"

Running Commands From Standard Input

If you want to run batch commands from the terminal standard input you can use the - option when launching the Nuxeo shell. The format of the commands is the same as the one described when running commands from a file.

Here is an example which will run the commands from my_batch_file file by using the Unix cat application and pipes:

cat my_batch_file | java -cp nuxeo-shell.jar org.nuxeo.shell.Main -

Running Batch Commands from the Command Line

If you just run a few short commands you can specify them directly in the command line of the Nuxeo Shell.

Example:

java -cp nuxeo-shell.jar org.nuxeo.shell.Main -e "connect -u Administrator -p Administrator http://localhost:8080/nuxeo/site/automation; ls"

Note that commands are separated using a semicolon character.

Limitations

You cannot run that way commands that contains illegal characters and needs to be escaped.

Samples

You will find sample scripts in $NUXEO_HOME/client/scripts/.

2 days ago Solen Guitter Don't show excerpt 'upgrade-9.2-drop-change-token' and add comment
2 years ago Solen Guitter 12
2 years ago Solen Guitter 11
3 years ago Julien Carsique 10
3 years ago Manon Lumeau 9
4 years ago Solen Guitter 8 | Added TOC
5 years ago Florent Guillaume 6
5 years ago Florent Guillaume 7 | Migrated to Confluence 4.0
5 years ago Solen Guitter 5 | Added related pages
7 years ago Bogdan Stefanescu 4
7 years ago Bogdan Stefanescu 3
7 years ago Bogdan Stefanescu 2
7 years ago Bogdan Stefanescu 1
History: Created by Bogdan Stefanescu