Changes

From Gramps

Gramps 5.1 Wiki Manual - Command Line

36,798 bytes added, 01:14, 22 May 2019
report action option: bullet list
{{man index|Gramps 5.1 Wiki Manual - Keybindings|Gramps 5.1 Wiki Manual - User Directory|5.1}}
{{languages|Gramps_5.1_Wiki_Manual_-_Command_Line}}
{{#vardefine:chapter|C}}
{{#vardefine:figure|0}}
This appendix provides the reference to the command line capabilities available when launching Gramps from the terminal.

== Start Gramps through the Command Line ==

Normally Gramps is started through the graphical user interface (GUI) on [[Gramps_5.1_Wiki_Manual_-_Getting_started#Start_Gramps|your platform]].

It is also possible to start Gramps using a command line interface (CLI). CLI use can
* produce reports that are not available via the GUI,
* create reports, do conversions etc. without opening a window and
* can provide [[Gramps_5.1_Wiki_Manual_-_Main_Window#Seeing_all_the_error_messages|extra information]] in the event of problems.

This section of the user manual describes how to start Gramps through the CLI, and the features that are available.

The way you start Gramps through the CLI depends on the operating system you are using.

For simplicity of description, the examples of use below are written from the point of view of running Gramps on Linux. The examples would need to be changed for other platforms.

=== Linux ===

Only the Linux platform is officially supported as Gramps developers use and test the source code on that platform, fixing any problems that arise due to upgrades.

Assuming you have used the standard Package Manager (either through a CLI or a GUI) for your Linux distribution, you start Gramps through the CLI by typing
gramps

=== MS Windows ===

{{stub}}
{{man warn|Outdated need to add info for new AIO installer CLI usage|See example usage https://github.com/gramps-project/addons-source/pull/121}}

MS Windows is a [[Download|community supported]] platform. If you install the [[All_In_One_Gramps_Software_Bundle_for_Windows|Windows AIO]] GrampsAIO32 or GrampsAIO64 executable, then this will place an icon on the desktop as well as a menu iten in the 'Start' menu.

What is the best way of knowing what command to type?

Starting Gramps from the command line (cmd.exe) depends on where you have chosen to install Gramps.
* Right click on the ??terminal Gramps application, or the corresponding item in the Start menu.
* Note down the starting directory.
* Select the whole of the command and copy (ctrl-C) it.
* From the Start menu, start cmd.exe.
* Change directory to the starting directory you noted down.
* Right click and select Paste.
* Press {{man key press|Enter}}.

For example, this might be:
cd "\Program Files\GrampsAIO64"
gramps

When the instructions below tell you to type something after the start command, you just type this after the last line, for example:
cd "\Program Files\GrampsAIO64"
gramps -L

There are other ways to install Gramps for MS Windows, but these are much more complicated and are not covered here.

=== Mac OS X ===

Mac OS X is a [[Download|community supported]] platform. If you download the Mac OS X disk image (.dmg), then you simply drag the application to your application folder (or anywhere else you want to store it) and start Gramps by double clicking on the application in the normal way.

To run from the command line, you'll need to start Terminal, found in Applications:Utilities.
Once you have a terminal window open, at the prompt type
/path/to/Gramps.app/Contents/MacOS/Gramps
If you installed Gramps in Applications along with most of your other apps, that would be
/Applications/Gramps.app/Contents/MacOS/Gramps
You may use any of the command-line options along with this. For example, to get a detailed listing of all of the Family Tree databases in your default Family Tree folder, you would use
/Applications/Gramps.app/Content/MacOS/Gramps -L

There are other ways to install Gramps for Mac OS X, but these are much more complicated and are not covered here.

== Python options ==

In the examples of different platforms above, and also in commands in various files you may see some options after the 'python' command, for example '-EO' in
"python3 -EO ..\share\gramps\gramps.py -L

It is important to distinguish between the '''python options''' in this case:
-EO
and the '''Gramps options''', in this case
-L

The '''python options''' that you may come across are:
* <code>-E</code> Ignore all PYTHON* environment variables, e.g. <code>PYTHONPATH</code> and <code>PYTHONHOME</code>, that might be set.
* <code>-O</code> Turn on basic optimizations. This changes the filename extension for compiled (bytecode) files from <code>.pyc</code> to <code>.pyo</code>. See also PYTHONOPTIMIZE.

The <code>-O</code> optimise flag has a number of effects in Gramps:
* If it is not turned on, an additional {{man menu|[[Gramps_5.1_Wiki_Manual_-_Tools#Debug|Debug]]}} entry appears in the {{man menu|[[Gramps_5.1_Wiki_Manual_-_Tools|Tools]]}} menu.
* If it is not turned on, [[Logging_system#So_how_logging_works_in_Gramps_after_all.3F|info logging messages are output]].
* If it is not turned on, [[Debugging_Gramps#Add_debug_statements|debug statements]] may be activated.
* If it is not turned on, additional features are available in the [[Gramps_5.1_Wiki_Manual_-_Plugin_Manager|Plugin Manager]].

The '''Gramps options''' are described below.

== Available Gramps options ==

This section provides the reference list of all command line options available in Gramps. If you want to know more than just a list of options, see next sections: [[#Operation|Operation]] and [[#Examples| Examples]]. The summary below is printed by
gramps -h
or
gramps --help

<pre>
Usage: gramps.py [OPTION...]
--load-modules=MODULE1,MODULE2,... Dynamic modules to load

Help options
-?, --help Show this help message
--usage Display brief usage message

Application options
-O, --open=FAMILY_TREE Open Family Tree
-U, --username=USERNAME Database username
-P, --password=PASSWORD Database password
-C, --create=FAMILY_TREE Create on open if new Family Tree
-i, --import=FILENAME Import file
-e, --export=FILENAME Export file
-r, --remove=FAMILY_TREE_PATTERN Remove matching Family Tree(s) (use regular expressions)
-f, --format=FORMAT Specify Family Tree format
-a, --action=ACTION Specify action
-p, --options=OPTIONS_STRING Specify options
-d, --debug=LOGGER_NAME Enable debug logs
-l [FAMILY_TREE_PATTERN...] List Family Trees
-L [FAMILY_TREE_PATTERN...] List Family Trees in Detail
-t [FAMILY_TREE_PATTERN...] List Family Trees, tab delimited
-u, --force-unlock Force unlock of Family Tree
-s, --show Show config settings
-c, --config=[config.setting[:value]] Set config setting(s) and start Gramps
-y, --yes Don't ask to confirm dangerous actions (non-GUI mode only)
-q, --quiet Suppress progress indication output (non-GUI mode only)
-v, --version Show versions
</pre>

The usage message is as follows:

gramps --usage

<pre>
Example of usage of Gramps command line interface

1. To import four databases (whose formats can be determined from their names)
and then check the resulting database for errors, one may type:
gramps -i file1.ged -i file2.gpkg -i ~/db3.gramps -i file4.wft -a tool -p name=check.

2. To explicitly specify the formats in the above example, append filenames with appropriate -f options:
gramps -i file1.ged -f gedcom -i file2.gpkg -f gramps-pkg -i ~/db3.gramps -f gramps-xml -i file4.wft -f wft -a tool -p name=check.

3. To record the database resulting from all imports, supply -e flag
(use -f if the filename does not allow Gramps to guess the format):
gramps -i file1.ged -i file2.gpkg -e ~/new-package -f gramps-pkg

4. To save any error messages of the above example into files outfile and errfile, run:
gramps -i file1.ged -i file2.dpkg -e ~/new-package -f gramps-pkg >outfile 2>errfile

5. To import three databases and start interactive Gramps session with the result:
gramps -i file1.ged -i file2.gpkg -i ~/db3.gramps

6. To open a database and, based on that data, generate timeline report in PDF format
putting the output into the my_timeline.pdf file:
gramps -O 'Family Tree 1' -a report -p name=timeline,off=pdf,of=my_timeline.pdf

7. To generate a summary of a database:
gramps -O 'Family Tree 1' -a report -p name=summary

8. Listing report options
Use the name=timeline,show=all to find out about all available options for the timeline report.
To find out details of a particular option, use show=option_name , e.g. name=timeline,show=off string.
To learn about available report names, use name=show string.

9. To convert a Family Tree on the fly to a .gramps xml file:
gramps -O 'Family Tree 1' -e output.gramps -f gramps-xml

10. To generate a web site into an other locale (in german):
LANGUAGE=de_DE; LANG=de_DE.UTF-8 gramps -O 'Family Tree 1' -a report -p name=navwebpage,target=/../de

11. Finally, to start normal interactive session type:
gramps

Note: These examples are for bash shell.
Syntax may be different for other shells and for Windows.

</pre>

=== List options ===
Print a list of known family trees:

;Sparse
-l, List Family Trees

gramps -l

<pre>
List of known Family Trees in your database path

/home/<~username>/.gramps/grampsdb/5a46c1c3 with name "Example Family Tree"
</pre>
{{-}}

;Detailed
-L, List Family Trees in Detail

gramps -L

<pre>
Gramps Family Trees:
Family Tree "Example Family Tree":
Database: SQLite
Database module location: /usr/lib/python3.5/sqlite3/__init__.py
Database module version: 2.6.0
Database version: 3.11.0
Last accessed: 30/12/17 09:29:37
Locked?: False
Number of citations: 2854
Number of events: 3432
Number of families: 762
Number of media: 7
Number of notes: 19
Number of people: 2157
Number of places: 1294
Number of repositories: 3
Number of sources: 4
Number of tags: 2
Path: /home/<~username>/.gramps/grampsdb/5a46c1c3
Schema version: 18.0.0
</pre>

{{man note|Note that dates are shown in the default LOCALE format.|You change that at the system level. For example, on POSIX-based systems you could use: <pre>LC_TIME=en_AU.UTF-8 gramps -L</pre>}}
{{-}}

=== Version options ===

-v or --version prints version of Gramps and dependencies,
information about environment settings and python and system paths

gramps -v

<pre>
Gramps Settings:
----------------
python : 3.5.2
gramps : 5.1.0
gtk++ : 3.18.9
pygobject : 3.20.0
pango : 1.38.1
cairo : 1.14.6
pycairo : 1.10.0
osmgpsmap : 1.0
GExiv2 : 0.10
ICU : 55.1
PyICU : 1.9.5
o.s. : linux
kernel : 4.4.0-104-generic

Environment settings:
---------------------
LANG : en_GB.UTF-8
LANGUAGE : en_GB:en_GB:en
GRAMPSI18N: not set
GRAMPSHOME: not set
GRAMPSDIR : not set
GRAMPS_RESOURCES : /gramps
PYTHONPATH:
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages

Non-python dependencies:
------------------------
Graphviz : 2.38
Ghostscr. : 9.18

System PATH env variable:
-------------------------
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

Databases:
-------------------------
bsddb :
version : 6.1.0
db version : 5.3.28
location : /usr/lib/python3/dist-packages/bsddb3/__init__.py
sqlite3 :
version : 3.11.0
py version : 2.6.0
location : /usr/lib/python3.5/sqlite3/__init__.py
</pre>

{{-}}

=== Format options ===

The format of any file destined for opening, importing, or exporting can be specified with the <pre>-f format</pre> option. The acceptable <tt>''format''</tt> values are listed below.

==== Full family tree support ====
These formats contain all your data that is present in a family tree.

* '''gramps''' - Gramps XML format: This format is available for import, and export. When not specified, it can be guessed if the filename ends with .gramps
* '''gpkg''' - Gramps package XML format: This format is available for import and export. When not specified, it can be guessed if the filename ends with .gpkg. This creates a zip package with your data as xml, and all your media files included
* '''grdb''' - pre Gramps 3.x database: This format is available for import to support the old file format of Gramps. Everything in the grdb file is imported. When not specified, it can be guessed if the filename ends with .grdb
* '''burn''' - GNOME iso burning: export, only available on GNOME where burn protocol exists

==== Reduced family tree support ====
These formats contain most, but not all data that can be created in Gramps

*'''ged''' - GEDCOM format: This format is available for import, and export. When not specified, it can be guessed if the filename ends with .ged
*'''gw''' - GeneWeb file: This format is available for import and export. When not specified, it can be guessed if the filename ends with .gw

==== Subset of your data ====
These formats contain a specific subset of your data

* '''csv''' - Comma Separated Value: This format is available for import and export. Be careful however, import must be as values created by the export function. Only a part of your data is contained in the output.
* '''vcf''' - VCard format: import and export
* '''vcs''' - VCalandar format: export
* '''def''' - old Pro-Gen format: import
* '''wft''' - Web Family Tree: This format is available for export only. When not specified, it can be guessed if the filename ends with .wft

=== Opening options ===

You can open a family tree, or you can ''open'' a file by importing it in an empty family tree.

To let Gramps handle this automatically, just supply the familytree or filename you want to open:

python gramps.py 'My Fam Tree'
python gramps.py JohnDoe.ged

The first opens a family tree, the second imports a GEDCOM into an empty family tree.

Additionally, you can pass Gramps the name of the family tree to be opened:

* use this option : <code>-O famtree</code> or <code>--open=famtree</code>

<code>-O</code>, Open of a family tree. This can be done also by just typing the name (name or database dir)

Examples:
python gramps.py 'Family Tree 1'
python gramps.py /home/cristina/.gramps/grampsdb/47320f3d
python gramps.py -O 'Family Tree 1'
python gramps.py -O /home/cristina/.gramps/grampsdb/47320f3d


{{Man tip| Tip |If no option is given, just a name, Gramps will ignore the rest of the command line arguments. Use the <code>-O</code> flag to open, <code>-i</code> to import, and do something with the data.}}

{{Man tip| Tip |Only family trees can be opened directly. For other formats, you will need to use the import option which will set up the empty database and then import data into it.}}

{{Man tip| Tip |Only a single family tree can be opened. If you need to combine data from several sources, you will need to use the import option.}}

=== Import options ===

The files destined for import can be specified with the <code>-i filename</code> or <code>--import=filename</code> option. The format can be specified with the <code>-f format</code> or <code>--format=format</code> option, immediately following the ''filename'' . If not specified, the guess will be attempted based on the ''filename''.

Example:
python gramps.py -i 'Family Tree 1' -i 'Family Tree 2'
python gramps.py -i test.grdb -i data.gramps

{{man tip | Tip |More than one file can be imported in one command. If this is the case, Gramps will incorporate the data from the next file into the database available at the moment.}}

When more than one input file is given, each has to be preceded by <code>-i</code> flag. The files are imported in the specified order, i.e. <code> -i file1 -i file2 </code> and <code> -i file2 -i file1 </code> might produce different Gramps IDs in the resulting database.

=== Export options ===

The files destined for export can be specified with the <code>-e filename</code> or <code>--export=filename</code> option. The format can be specified with the <code>-f</code> option immediately following the ''filename'' . If not specified, the guess will be attempted based on the ''filename'' . For iso format, the ''filename'' is actually the name of directory the Gramps database will be written into. For gramps-xml, gpkg, gedcom, wft, geneweb, and gramps-pkg, the ''filename'' is the name of the resulting file.

-e, export a family tree in required format. It is not possible to export to a family tree.

Example:
python gramps.py -i 'Family Tree 1' -i test.grdb -f grdb -e mergedDB.gramps
Note that above does not change 'Family Tree 1' as everything happens via a temporary database, whereas:
python gramps.py -O 'Family Tree 1' -i test.grdb -f grdb -e mergedDB.gramps
will import test.grdb into Family Tree 1, and then export to a file !

{{man tip| Exporting more files |More than one file can be exported in one command. If this is the case, Gramps will attempt to write several files using the data from the database available at the moment.}}

When more than one output file is given, each has to be preceded by <code>-e</code> flag. The files are written one by one, in the specified order.

=== Action options ===

The action to perform on the imported data can be specified with the <code>-a action</code> or <code>--action=action</code> option. This is done after all imports are successfully completed.

The following actions remain the same:

*''report'': This action allows producing reports from the command line.

*''tool'': This action allows to run a tool from the command line.

Reports and tools generally have many options of their own, so these actions should be followed by the report/tool option string. The string is given using the <code>-p option_string</code> or <code>--options=option_string</code> option.

The actions available in older versions of Gramps which were relocated in Gramps 3.3 are:

*''summary'': This action was the same as {{man menu|Reports ->View ->Summary}}. In Gramps 3.3 it was replaced by (or renamed to) '''-a report -p name=summary'''.

*''check'': This action was the same as {{man menu|Tools ->Database Processing ->Check and Repair}}. In Gramps 3.3 it was replaced by (or renamed to) '''-a tool -p name=check'''.

==== report action option ====
You can generate most reports from the command line using the report action.

An example:
gramps -O "Family Tree 1" -a report -p "name=family_group,style=default,off=html,of=test.html"

You can provide the css style to use here with the css option:
gramps -O "Family Tree 1" -a report -p "name=family_group,style=default,off=html,of=test.html,css=Web_Nebraska.css"
or without css in the html output:
gramps -O "Family Tree 1" -a report -p "name=family_group,style=default,off=html,of=test.html,css="

{{man tip| Report option string |The report option string should satisfy the following conditions:<br />* It must not contain any spaces (due to the general nature of the command line interface). If some arguments need to include spaces, the string should be enclosed with quotation marks.<br />* Option string must list pairs of option names and values. Within a pair, option name and value must be separated by the equal sign.<br />* Different pairs must be separated by commas.}}

Most of the report options are specific for every report. However, there are some common options.

*<code>name=report_name</code>: This mandatory option determines which report will be generated.
{{man note|Report names|If the supplied report_name does not correspond to any available report, an error message will be printed followed by this list of available reports.<br />
<pre>
Available names are:
ancestor_chart - Ancestor Tree
ancestor_report - Ahnentafel Report
birthday_report - Birthday and Anniversary Report
calendar - Calendar
descend_chart - Descendant Tree
descend_report - Descendant Report
det_ancestor_report - Detailed Ancestral Report
det_descendant_report - Detailed Descendant Report
endofline_report - End of Line Report
family_descend_chart - Family Descendant Tree
family_group - Family Group Report
familylines_graph - Family Lines Graph
fan_chart - Fan Chart
hourglass_graph - Hourglass Graph
indiv_complete - Complete Individual Report
kinship_report - Kinship Report
navwebpage - Narrated Web Site
notelinkreport - Note Link Report
number_of_ancestors - Number of Ancestors Report
place_report - Place Report
records - Records Report
rel_graph - Relationship Graph
statistics_chart - Statistics Charts
summary - Database Summary Report
tag_report - Tag Report
timeline - Timeline Chart
WebCal - Web Calendar
</pre>}}
*<code>of=</code>: output filename and optional destination folder/directory eg: <code>of="C:\Users\<username>\Desktop\FamilyTree.odt"</code>
*<code>off=</code>: output format. These are the extension an output format makes available, eg, pdf, html, doc, ...
*<code>style=</code>: for text reports, the stylesheet to use. Defaults to 'default'.
*<code>show=all</code>: This will produce the list of names for all options available for a given report.
*<code>show=option_name</code>: This will print the description of the functionality supplied by the option_name, as well as what are the acceptable types and values for this option.

So, to learn to use a report, do for example:
gramps -O "Family Tree 1" -a report -p "name=family_group,show=all"

{{man tip| Tip |If an option is not supplied, the last used value will be used. If this report has never been generated before, then the value from last generated report will be used when applicable. Otherwise, the default value will be used.}}

When more than one output action is given, each has to be preceded by <code>-a</code> flag. The actions are performed one by one, in the specified order.

{{man tip| lists |Some reports have options or arguments which are interpreted (by the report) to be on multiple lines. For instance some reports allow you to format how the information will be shown, perhaps with a name on one line and the person's birth date on the next line. Such multiple-line options or arguments are called "lists" by Gramps.}}

On the command line such lists must always start with a left square bracket <code>[</code> and must always end with a right square bracket <code>]</code> but since such square brackets are usually "special" to the "shell" (they mean something to the command interpreter
you are typing the command to), you must "escape" them so that they are ignored by your shell.

The details vary with each shell but (in linux/UNIX) usually you can precede such a square bracket with a backslash <code>\</code> or put quotation marks around the square bracket, usually either "single" or "double" ones.

The Hourglass Graph report allows you to put a "note" at the top of the report and such a "note" is an example of a "list" option. Here is an example:
gramps -O "Family Tree 1" -a report -p name=hourglass_graph,note='[line one,line two]'
which shows that inside such a list different lines are separated by commas, and that spaces are acceptable since the quotation marks are already there for the square brackets.

But if you want to have a comma inside your report you have to somehow tell Gramps that comma is not one which separates lines. You do that by enclosing the line with the comma in quotation marks (either single or double).

But if you are already using a set of quotation marks (to enclose your square brackets) you have to use the other type to enclose
the line with your comma. Here is an example:
gramps -O "Family Tree 1" -a report -p name=hourglass_graph,note="['line one, also line one','line two, also line two']"

It is possible to include any character in a list but the details are beyond the scope of this command-line introduction to Gramps.

You will need to know the precise methods available in your particular command shell interpreter to include a character which is "special" to your shell or "special" to Gramps (like the comma in the example above) but in general you will have to "escape" it twice, once to your shell and once again to Gramps, since you don't want your shell to think it is some instruction it should pay attention to and you don't want Gramps to think that either.

==== tool action option ====
You can run most tools from the command line using the 'tool' action.
To see which ones, say:
gramps -O "Family Tree 1" -a tool -p show=all
To see a tool's available options, for instance the "verify" tool:
gramps -O "Family Tree 1" -a tool -p name=verify,show=all
To run a tool, for instance the "verify" tool:
gramps -O "Family Tree 1" -a tool -p name=verify

{{man note|Tool names|If the supplied tool_name does not correspond to any available tool, an error message will be printed followed by this list of available tools.<br />
<pre>
Available names are:
check - Check and Repair Database
chtype - Rename Event Types
dgenstats - Dump Gender Statistics
evname - Extract Event Description
rebuild - Rebuild Secondary Indexes
rebuild_genstats - Rebuild Gender Statistics
rebuild_refmap - Rebuild Reference Maps
reorder_ids - Reorder Gramps IDs
test_for_date_parser_and_displayer - Check Localized Date Displayer and Parser
testcasegenerator - Generate Testcases for Persons and Families
verify - Verify the Data
</pre>}}

==== book action option ====
{{man note|New feature|Added in Gramps 5.1}}
You can run books from the command line using the 'book' action.
To see which ones, say:
gramps -O "Family Tree 1" -a book
To see a book's available options, for instance a book called "mybook":
gramps -O "Family Tree 1" -a book -p name=mybook,show=all
To run a book, for instance a book called "mybook":
gramps -O "Family Tree 1" -a book -p name=mybook

{{man note|Book names|If the supplied book_name does not correspond to any available Book, an error message will be printed followed by this list of available Books. eg: Example listing only as the Books will be whatever you have named them.<br />
<pre>
Available names are:
Granny Jones
Grampa John
Smith Family History
</pre>}}

=== Force unlock option ===

*<code>-u</code>: you can extend the <code>-O</code> flag with <code>-u</code> to force a locked family to be unlocked. This allows you to recover from a crash that leaves the family tree (database) locked, from the command line.

An example (to unlock the "Family Tree 1" database):
:<code>gramps -O "Family Tree 1" -a report -u > /dev/null</code>

{{man note|Note|It is not possible to open family trees that need repair from the command line.}}

See also:
* [[Gramps_5.1_Wiki_Manual_-_Manage_Family_Trees#Unlocking_a_Family_Tree|Manage Family Trees:Unlocking a Family Tree]]

=== Configuration (config) option ===
When all configuration variable(s) are set Gramps will start with these new values.

These options can takes three forms:
{{man note|Note|Except for examples <tt>1</tt> and <tt>3.2</tt>, All the following examples, use <code>behavior.database-path</code> as the configuration variable to change.}}

;1) See all config values: <code>-s</code> or <code>--show</code>
<br>For example:
gramps --show
<pre>
Gramps config settings from /home/<~username>/.gramps/gramps50/gramps.ini:
export.proxy-order=[['privacy', 0], ['living', 0], ['person', 0], ['note', 0], ['reference', 0]]

database.compress-backup=True
database.backend='bsddb'
database.backup-path='/home/<~username>'
database.port=''
database.autobackup=0
database.path='/home/<~username>/.gramps/grampsdb'
database.host=''
database.backup-on-exit=True

geography.lock=False
....
</pre>

{{-}}

;2) See a single config value: <code>--config=database.path</code> or <code>-c database.path</code>
<br>For example:
gramps --config=database.path
<pre>
Current Gramps config setting: database.path:'/home/<~username>/.gramps/grampsdb'
</pre>

3) Set a value: <code>--config=behavior.database-path:'/media/mydb'</code> or <code>-c behavior.database-path:'/media/mydb'</code>
<br>For example:

3.1) Set a value to its default: <code>--config=behavior.database-path:DEFAULT</code> or <code>-c behavior.database-path:DEFAULT</code>
<br>For example:

3.2) Set more than one value: <code>--config=behavior.use-tips:False --config=behavior.autoload:True</code> or <code>-c behavior.use-tips:False -c behavior.autoload:True</code>
<br>For example:

== Operation ==

If the first argument on the command line does not start with a dash (i.e. no flag), Gramps will attempt to open the file with the name given by the first argument and start an interactive session, ignoring the rest of the command line arguments.

If the <code>-O</code> flag is given, then Gramps will try opening the supplied file name and then work with that data, as instructed by the further command line parameters.

{{man note|1=Note |2=Only one file can be opened in a single invocation of Gramps. If you need to get data from multiple sources, use the importing options by using <code>-i</code> flag.}}

With or without the <code>-O</code> flag, there could be multiple imports, exports, and actions specified further on the command line by using <code>-i</code> , <code>-e</code> , and <code>-a</code> flags.

The order of <code>-i</code> , <code>-e</code> , or <code>-a</code> options with respect to each does not matter. The actual execution order always is: all imports (if any) -> all exports (if any) -> all actions (if any).

{{man note| Note |But opening must always be first!}}

If no <code>-O</code> or <code>-i</code> option is given, Gramps will launch its main window and start the usual interactive session with the empty database, since there is no data to process, anyway. (Unless you have already expressed a "preference" that it start with the last database it used.)

If no <code>-e</code> or <code>-a</code> options are given, Gramps will launch its main window and start the usual interactive session with the database resulted from opening and all imports (if any). This database resides in a directory under the ''<code>~/.gramps/grampsdb/</code>'' directory.

Any errors encountered during import, export, or action, will be either dumped to stdout (if these are exceptions handled by Gramps) or to stderr (if these are not handled). Use usual shell redirections of stdout and stderr to save messages and errors in files.

== Examples ==

*To import four databases (whose formats can be determined from their names) and then check the resulting database for errors, one may type:

:<code>gramps -i file1.ged -i file2.gpkg -i ~/db3.gramps -i file4.wft -a check</code>

*To explicitly specify the formats in the above example, append filenames with appropriate -f options:

:<code>gramps -i file1.ged -f gedcom -i file2.gpkg -f gramps-pkg -i ~/db3.gramps -f gramps-xml -i file4.wft -f wft -a check</code>

*To record the database resulting from all imports, supply -e flag (use -f if the filename does not allow Gramps to guess the format):

:<code>gramps -i file1.ged -i file2.gpkg -e ~/new-package -f gramps-pkg</code>

*To save any error messages of the above example into files outfile and errfile, run:

:<code>gramps -i file1.ged -i file2.dpkg -e ~/new-package -f gramps-pkg >outfile 2>errfile </code>

*To import three databases and start interactive Gramps session with the result:

:<code>gramps -i file1.ged -i file2.gpkg -i ~/db3.gramps </code>

*To open a database and, based on that data, generate timeline report in PDF format putting the output into the my_timeline.pdf file:

:<code>gramps -O 'Family Tree 1' -a report -p name=timeline,off=pdf,of=my_timeline.pdf </code>

{{man tip|1=Listing report options |2=Use the <code>''name=timeline,show=all''</code> to find out about all available options for the timeline report. To find out details of a particular option, use <code>''show=option_name''</code> , e.g. <code>''name=timeline,show=off''</code> string. To learn about available report names, use <code>''name=show''</code> string.}}

*To convert the bsddb database on the fly to a .gramps xml file:

:<code>gramps -O 'Family Tree 1' -e output.gramps -f gramps-xml</code>

* To generate a web site into an other locale (in german):

:<code>LANGUAGE=de_DE; LANG=de_DE.UTF-8 gramps -O 'Family Tree 1' -a report -p name=navwebpage,target=/../de </code>

*Finally, to start normal interactive session type:

:<code>gramps</code>

== Environment variables==

{{man warn|Warning|Gramps can take advantage of the following environment variables<br />('''Only change them if you know what are you doing.''')}}

===GRAMPSHOME===
* '''GRAMPSHOME''' - if set, override default path to profile allowing user to use an external network drive to store data and all settings. For technically advanced users who run multiple versions of Gramps, setting a different $GRAMPSHOME is a way to avoid interference between the different versions in the Gramps user directory.
For example <pre>GRAMPSHOME=$HOME/familytrees/paternal</pre>

===LANG, LANGUAGE, LC_MESSAGE, LC_TIME ===
* '''LANG''', '''LANGUAGE''', '''LC_MESSAGES''', and '''LC_TIME''' - are used by Gramps to determine which language file(s) should be loaded. See locale(1) for a general discussion of '''LANG''', '''LC_MESSAGES''', and '''LC_TIME'''. Note that in addition to setting date formats (which are overridden in Gramps with Preferences settings) '''LC_TIME''' also sets the language used for words in dates like month and day names and ''in the context of dates'' words like ''about'', ''between'', and ''before''. '''LANGUAGE''' is a comma-separated list of language codes (''not locales'', though certain languages like pt_BR or cn_TW are regional variants) that sets a preference-ordered list of desired translations. It will override '''LANG''' but not '''LC_MESSAGES''' or '''LC_TIME'''.

{{man note|MacOSX|Because of the way launching with Finder works, the environment variables for the Gramps.app bundle are hard-coded in <code>Gramps.app/Contents/MacOS/Gramps</code>. If for some reason you need to change them, edit that file with TextEdit; be sure to save it back as plain text. See as well [[Run_GRAMPS_in_another_locale#Change_Mac_OS_X_application_defaults|setting locale]] for an alternative to using the '''LANG''' and '''LANGUAGE''' environment variables.}}

===GRAMPSI18N===
* [[Translating_Gramps#.24GRAMPSI18N_.28for_your_locale.29| $GRAMPSI18N (for your locale) ]] - The LANG assumes the Gramps translations are installed globally. If this is not the case, you need to give Gramps the directory where the translations will be found. A translation is called <code>gramps.mo</code>, you can find it in linux with the locate command. For example, if you have Swedish in directory <code>/home/me/gramps/mo/sv/gramps.mo</code>, you can direct Gramps there using:
GRAMPSI18N=/home/me/gramps/mo LC_ALL=C.UTF-8 LANG="sv" python3 gramps

===GRAMPSDIR===
* The environment variable GRAMPSDIR is the path to your [[Translating_Gramps#gramps.sh|Gramps directory]].

===GRAMPS_RESOURCES===
* The environment variable GRAMPS_RESOURCES is the path to Gramps builtin resources files. You should only change this if you are using Gramps from source code or a custom environment. An indicator that you need to set this variable is if you receive one of the following errors:
** ''Encoding error while parsing resource path''
** ''Failed to open resource file''
** ''Resource Path {invalid/path/to/resources} is invalid''
** ''Unable to determine resource path''

Example [[Linux:Build_from_source#Running_from_a_tarball_release|usage]]:
GRAMPS_RESOURCES=/home/benny/gramps/branches/maintenance/gramps50/build/lib.linux-x86_64-2.7/ PYTHONPATH=$GRAMPS_RESOURCES:$PYTHONPATH ./gramps

{{-}}
{{man index|Gramps 5.1 Wiki Manual - Keybindings|Gramps 5.1 Wiki Manual - User Directory|5.1}}
{{languages|Gramps_5.1_Wiki_Manual_-_Command_Line}}
{{grampsmanualcopyright}}

[[Category:Documentation]]

Navigation menu