Next: Notes for the MacOS X app, Up: Running LilyPond
The lilypond
executable may be called as follows from the command line.
lilypond [option]... file...
When invoked with a filename that has no extension, the .ly
extension is tried first. To read input from stdin, use a
dash (-
) for file.
When filename.ly is processed it will produce
filename.tex as output (or filename.ps for PostScript
output). If filename.ly contains more than one \score
block, then the rest of the scores will be output in numbered files,
starting with filename-1.tex. Several files can be specified;
they will each be processed independently. 1
The following options are supported:
-e,--evaluate=
expr-e
options may be given, they will be evaluated
sequentially.
The expression will be evaluated in the guile-user
module, so
if you want to use definitions in expr, use
lilypond -e '(define-public a 42)'
on the command-line, and include
#(use-modules (guile-user))
at the top of the .ly
file.
-f,--format=
formatformat
are
svg
, ps
, pdf
, png
, tex
, dvi
.
Example: lilypond -fpng filename.ly
-b,--backend=
formatformat
are
tex
texstr
.textmetrics
file, which contains the
extents of strings of text. Warning: this functionality is
currently missing due to heavy restructuring of the source code.
ps
eps
This mode is used by default by lilypond-book.
svg
scm
Example: lilypond -bsvg filename.ly
-d,--define-default=
var=
valno-
may be prefixed to var, e.g.
-dno-point-and-click
is the same as
-dpoint-and-click='#f'
Another notable option is
-dpaper-size=\"letter\"
Note that the string must be enclosed in escaped quotes ( \"
).
Setting the -dhelp
option will print a summary of the options
available, and exit.
-h,--help
-H,--header=FIELD
--include, -I=
directory-i,--init=
file-o,--output=
FILE.pdf
for pdf, .tex
for tex, etc).
--ps
--dvi
-b tex
.
--png
--ps
. The resolution in DPI of the image may be set with
-dresolution=110
--pdf
--ps
.
--preview
--no-pages
--preview
.
-s,--safe
.ly
input.
When LilyPond formatting is available through a web server, either the
--safe
or the --jail
option MUST be passed. The
--safe
option will prevent inline Scheme code from wreaking
havoc, for example
#(system "rm -rf /") { c4^#(ly:export (ly:gulp-file "/etc/passwd")) }
The --safe
option works by evaluating in-line Scheme
expressions in a special safe module. This safe module is derived from
GUILE safe-r5rs module, but adds a number of functions of the
LilyPond API. These functions are listed in scm/safe-lily.scm.
In addition, --safe
disallows \include
directives and
disables the use of backslashes in TeX strings.
In --safe
mode, it is not possible to import LilyPond variables
into Scheme.
--safe
does not detect resource overuse. It is still
possible to make the program hang indefinitely, for example by feeding
cyclic data structures into the backend. Therefore, if using LilyPond
on a publicly accessible webserver, the process should be limited in
both CPU and memory usage.
Note that --safe
will prevent many useful LilyPond snippets from
being compiled. For a softer but secure alternative you can use the
--jail
option.
-j,--jail=
user,
group,
jail,
dirThe --jail
option provides a more flexible alternative to
--safe
when LilyPond formatting is available through a web
server or whenever LilyPond executes externally provided
sources.
The --jail
option works by changing the root of LilyPond to
jail just before starting the actual compilation process. The user
and group are then changed to match those provided, and the current
directory is changed to dir. This setup guarantees that it is not
possible (at least in theory) to escape from the jail. Note that for
--jail
to work LilyPond must be run as root, which is usually
accomplished in a safe way using sudo.
Setting up a jail is a slightly delicate matter, as we must be sure that LilyPond is able to find whatever it needs to compile the source inside the jail. A typical setup comprises the following items:
noexec
, nodev
, and
nosuid
. In this way, it is impossible to run executables or to
write directly to a device from LilyPond. If you do not want to create a
separate partition, just create a file of reasonable size and use it to
mount a loop device. A separate filesystem also guarantees that LilyPond
cannot write more space than it is allowed.
If problems arise, the simplest way to trace them down is to run
LilyPond using strace, which will allow you to determine which
files are missing.
noexec
it is impossible to execute any external
program. Therefore LilyPond must be run with a backend that does not
require any such program. As we already mentioned, it must be also run
with superuser privileges (which, of course, it will lose immediately),
possibly using sudo. It is a good idea to limit the number of
seconds of CPU time LilyPond can use (e.g., using ulimit
-t), and, if your operating system supports it, the amount of memory
that can be allocated.
-v,--version
-V,--verbose
-w,--warranty
Lilypond
recognizes the following environment variables:
LILYPOND_DATADIR
LANG
LILYPOND_GC_YIELD
70
.
[1] The status of
GUILE is not reset after processing a .ly
file, so be careful
not to change any system defaults from within Scheme.
Next: Notes for the MacOS X app, Up: Running LilyPond
This page is for LilyPond-2.10.33 (stable-branch).