Skip to main content

Command line

njmule is njMule's command line. Run without a task, it starts the engine headless and keeps it running until you stop it; with a task (a search, a hash, an import, a remote command), it does that and exits. It is njmule.exe on Windows (on the PATH after the installer), /Applications/njMule.app/Contents/MacOS/njmule on macOS and njmule in /usr/bin with the Linux packages.

The desktop app, njmule-gui, is the window that starts njmule beside it and shows its interface. It takes only a few options: ed2k links, which it hands to the desktop window already open (or opens one with them); --config-dir <dir>, the profile of the engine it starts, and --log-level <level>, which it passes to that engine; --remote-url <url>, which shows another njMule instead (Remote njMule); --version; and --restore-links, which it passes to the engine. The installer and njMule's updates run a few more of its own. Every other task runs with njmule.

Quote the links

ed2k links contain |, which shells read as a pipe. Always put them in quotes: njmule "ed2k://|file|example.iso|1048576|0123456789ABCDEF0123456789ABCDEF|/".

The full help​

This is what njmule --help prints for this version:

Usage: njmule [-hV] [--adopt-emule-identity] [--api-token] [--check-update]
[--dry-run] [--exit] [--global] [--headless] [--import-downloads]
[--kad] [--license] [--new-api-token] [--notice]
[--remove-profile] [--restore-links] [--update] [--warranty]
[--webui-api] [--webui-lan] [--webui-no-guest] [--webui-password]
[--yes] [--add-servers=<server.met>] [--config-dir=<dir>]
[--connect-server=<host:port>] [--hello=<host:port>]
[--import-emule=<dir>] [--kad-bootstrap=<host:port>]
[--log-level=<level>] [--remote-url=<url>]
[--search=<expression>] [--service=<action>]
[--webui-guest-password-file=<file>]
[--webui-password-file=<file>] [--webui-port=<port>]
[--webui-host=<name>[,<name>...]]... [--webui-proxy=<address>[,
<address>...]]... [--download=<ed2k link>...]...
[--hash=<file>...]... [--remote=<command>...]...
[--share=<dir>...]... [<ed2k link>...]
[<ed2k link>...] add these downloads, handing them to the njMule
already running with the same configuration, if
any (as a browser does with a clicked link)
--add-servers=<server.met>
add the servers of another client's server.met
--adopt-emule-identity with --import-emule: also take eMule's user hash,
key and credits, from the next start (never run
both with one identity)
--api-token print the token of the remote-control API, making
one if needed
--check-update look for a new version of njMule on GitHub, print
it and exit: 0 when this one is the newest, 100
when a newer one is out, 1 when the check failed
--config-dir=<dir> keep all data below <dir> instead of the system
locations
--connect-server=<host:port>
connect to this server (any known one when a
search needs a server)
--download=<ed2k link>...
download the files of these links (from their
sources and, with --connect-server, the
server's), then exit
--dry-run with --import-emule: only report
--exit ask the njMule running on this configuration to
save and exit, and wait for it (30 s at most)
--global search the other known servers too, over UDP
-h, --help print this help and exit
--hash=<file>... print the ed2k link (with AICH hash) of each file
and exit
--headless accepted for older start commands: njmule never
opens a window
--hello=<host:port> say hello to a client, print its answer and exit
--import-downloads with --import-emule: also copy eMule's downloads
(paused ones while it runs)
--import-emule=<dir> take servers, Kad contacts, known files, shared
directories and preferences from eMule's config
directory (only read), then exit
--kad search on Kad instead of the servers
--kad-bootstrap=<host:port>
join Kad through this node (its UDP port), e.g. a
running eMule
--license print the GNU General Public License and exit
--log-level=<level> ERROR, WARN, INFO, DEBUG or TRACE (overrides the
preferences)
--new-api-token replace the token of the remote-control API, print
the new one and exit
--notice print copyright, attribution and third-party
notices
--remote=<command>... run a command in the njMule running on this
configuration (or at --remote-url), through its
remote-control API: --remote help lists them
--remote-url=<url> the API of another njMule, as http://host:
4711/api/v1, where the command of --remote runs;
the token comes from the NJMULE_API_TOKEN
environment variable (njmule-gui --remote-url
<url> shows that njMule in the desktop app)
--remove-profile delete this njMule's settings, lists, identity,
unfinished downloads, caches and logs, after
asking, and exit; the completed downloads stay
(stop njMule first)
--restore-links give ed2k links back to what opened them before
the desktop app took them, if it still has them,
stop it from starting at login, and exit (the
uninstallers run it)
--search=<expression> search, print the results and exit
--service=<action> install, uninstall, start, stop or status of
njMule as a Windows service, which runs it
headless with its web interface on the profile
in %ProgramData%\njMule as the virtual account
NT SERVICE\njMule (Windows asks for the
administrator's rights); install takes the web
interface options, asks for its password when
none is set, and restarts a service that runs
--share=<dir>... share the files of these directories too
(remembered), besides the incoming one
--update look for a new version of njMule, download it,
check it against its signed information and
install it where njMule may replace itself (the
Windows installer and zip, the macOS app, the
Linux archives; elsewhere it tells how), then
exit; stop njMule first (njmule --exit)
-V, --version print the version and exit
--warranty print the warranty disclaimer and exit
--webui-api with --webui-password, --webui-password-file or
--service=install: let the remote-control API
answer too, to holders of its token
--webui-guest-password-file=<file>
with --webui-password, --webui-password-file or
--service=install: a guest, who may only look,
logs in with the first line of <file>, which is
not the web interface password
--webui-host=<name>[,<name>...]
with --webui-password, --webui-password-file or
--service=install: a host name the web interface
answers to, such as a LAN name or a reverse
proxy's (repeatable); otherwise only localhost
and, with --webui-lan, IP addresses
--webui-lan with --webui-password, --webui-password-file or
--service=install: let other computers connect
(otherwise only this one)
--webui-no-guest with --webui-password, --webui-password-file or
--service=install: let no guest log in any more
--webui-password ask for a password for the web interface, turn the
interface on (from the next start) and exit
--webui-password-file=<file>
the web interface password is the first line of
<file> (a Docker or systemd secret, for
example): set at each start, turning the
interface on and keeping its other options as
saved unless given too, or with --webui-password
set without asking
--webui-port=<port> with --webui-password, --webui-password-file or
--service=install: the port of the web interface
--webui-proxy=<address>[,<address>...]
with --webui-password, --webui-password-file or
--service=install: a reverse proxy trusted to
name its client in X-Forwarded-For, an address,
a CIDR block or a range (repeatable); otherwise
every request is its own client
--yes with --remove-profile: do not ask

Run the engine​

OptionWhat it does
(none)Runs the engine headless until Ctrl+C, SIGTERM or njmule --exit
--headlessChanges nothing: njmule always runs without a window. It is still accepted, for the scripts and units that give it
--config-dir <dir>Keeps all data below <dir> (config, data, temp, cache, logs, gui, incoming) instead of the system's folders
--log-level <level>ERROR, WARN, INFO, DEBUG or TRACE for this run, whatever the options say
--share <dir>...Shares these folders too, besides the incoming one, and remembers them
--add-servers <server.met>Adds the servers of another client's server.met
--connect-server <host:port>Connects to this server
--kad-bootstrap <host:port>Joins Kad through this node (its UDP port), such as an eMule running nearby

These options run their task and then keep the engine running:

njmule --config-dir /srv/njmule --log-level DEBUG
njmule --share /data/music /data/books
njmule --add-servers ~/server.met --connect-server 203.0.113.10:4661
njmule --kad-bootstrap 192.0.2.20:4672

--config-dir works with every other option: give it to each command that should reach that profile, such as njmule --config-dir /srv/njmule --exit.

Add downloads​

Links given without an option go to the njMule already running on the same configuration, desktop or headless, as a browser hands over a clicked link; when none runs, njmule starts headless with them and keeps running.

njmule "ed2k://|file|example.iso|1048576|0123456789ABCDEF0123456789ABCDEF|/"

A file link becomes a download, a server link adds the server, and a server-list or nodes.dat link takes the servers or Kad contacts found at its address. To download and then exit instead, use --download.

Stop a running njMule​

njmule --exit

Asks the njMule running on this configuration (desktop or headless) to save and exit, and waits for it, 30 seconds at most. It fails with exit code 1 when no njMule runs there, or when it still runs after that time.

One-off network tasks​

These start the engine, do their task and exit. The engine then makes no connection of its own: it connects only as the task asks.

OptionWhat it does
--search <expression>Searches on a server (the one of --connect-server, or any known one), prints the results with their links and exits
--globalWith --search: asks every other known server too, over UDP
--kadWith --search: searches on Kad instead, once it knows enough nodes
--download <ed2k link>...Downloads these files from the sources in their links and, with --connect-server, from the server's; prints the progress and exits when each one has finished or failed
--hello <host:port>Says hello to a client, prints its answer and stays connected 30 seconds
--hash <file>...Prints the ed2k link of each file, with its AICH hash, and the hashing speed; needs no engine
njmule --search "lumenos iso"
njmule --search "lumenos iso" --global
njmule --search "lumenos" --kad
njmule --connect-server 203.0.113.10:4661 --download "ed2k://|file|lumenos.iso|…|/"
njmule --hash ~/Videos/holiday.mkv

A search waits up to 3 minutes for a server login (or for Kad to know enough nodes) and up to 90 seconds for results, and ends 3 seconds after the last one. Each result is printed as its number of sources, its size and its name, with its link on the next line.

Import from eMule​

OptionWhat it does
--import-emule <dir>Takes the servers, Kad contacts, known files, shared folders and preferences from eMule's configuration folder, only reading it, then exits
--dry-runOnly tells what would be imported
--adopt-emule-identityAlso takes eMule's user hash, key and credits, from the next start of njMule
--import-downloadsAlso copies eMule's unfinished downloads (paused ones while eMule runs)
njmule --import-emule "D:\eMule\config" --dry-run
njmule --import-emule "D:\eMule\config" --adopt-emule-identity --import-downloads

Never run eMule and njMule with the same identity at once. See Import from eMule for what each part does.

Web interface​

OptionWhat it does
--webui-passwordAsks for a new password twice, turns the interface on from the next start and exits
--webui-password-file <file>Takes the password from the first line of <file>: with --webui-password it sets it without asking; alone, at every start before running njMule
--webui-port <port>The port (4711 by default)
--webui-lanLets other computers connect; otherwise only this one
--webui-host <name>A host name the interface answers to besides localhost (repeatable, or separated by commas)
--webui-proxy <address>A reverse proxy trusted to name its client in X-Forwarded-For: an address, a CIDR block or a range (repeatable, or separated by commas)
--webui-apiLets the remote-control API answer too, to holders of its token
--webui-guest-password-file <file>Lets a guest, who may only look, sign in with the first line of <file>, which must differ from your password
--webui-no-guestLets no guest sign in any more

The last seven only come with --webui-password, --webui-password-file or --service=install. With --webui-password they set LAN access, the host names and the proxies anew (what you leave out is turned off; the port, the API and the guest stay as they were). With --webui-password-file alone, at every start, or with --service=install alone, only what you give changes: the rest keeps what was saved, the host names set in the web interface included.

njmule --webui-password --webui-lan --webui-host nas.local --webui-api
njmule --webui-password-file /run/secrets/njmule_webui_password --webui-lan

See Web interface, Security and Reverse proxy.

Remote control​

OptionWhat it does
--remote <command>...Runs a command in the njMule running on this configuration through its API; --remote help lists the commands
--remote-url <url>The API of another njMule, as http://192.0.2.10:4711/api/v1: with --remote the command runs there. Without it njmule refuses it: njmule-gui --remote-url <url> shows that njMule in the desktop app's window
--api-tokenPrints the API token, making one if there is none
--new-api-tokenReplaces the API token, prints the new one and exits; the old one stops working

--remote takes every word after it as the command, so put it last:

njmule --remote status
njmule --config-dir /srv/njmule --remote search kad lumenos
NJMULE_API_TOKEN=… njmule --remote-url http://192.0.2.10:4711/api/v1 --remote downloads

See Remote control for every command.

Updates​

OptionWhat it does
--check-updateLooks for a new version on GitHub, prints it with how to install it, and exits with 0, 100 or 1 (see below)
--updateLooks for a new version, downloads it, checks it against its signed information and installs it where njMule may replace itself; elsewhere it tells how. Stop njMule first

Both start an engine on the configuration, so they work only while no njMule runs on it. With njMule running, ask it instead: njmule --remote update check. See Updates.

System​

OptionWhat it does
--service=<action>Windows only: install, uninstall, start, stop or status of the service "njMule" (Windows service)
--restore-linksGives ed2k links back to the program that opened them before the desktop app took them, if it still has them, turns the start at login off, and exits; the uninstallers of Windows and macOS run it
--remove-profileDeletes this profile's settings, lists, identity, unfinished downloads, caches and logs after asking, and exits, giving the ed2k links back and turning the start at login off first; the completed downloads stay. Stop njMule first
--yesWith --remove-profile: does not ask
njmule --remove-profile
njmule --config-dir /srv/njmule --remove-profile --yes

Information​

OptionWhat it does
-h, --helpPrints the help
-V, --versionPrints the version and the license
--licensePrints the GNU General Public License
--warrantyPrints the warranty disclaimer
--noticePrints the copyright, attribution and third-party notices

Combining options​

njMule refuses, with a usage error, options that would be silently ignored together:

  • --exit, --restore-links, --check-update, --update and --remove-profile come alone, besides --config-dir, --log-level and --headless (and --yes for --remove-profile), and never with links.
  • --global and --kad need --search, and not both.
  • --dry-run, --adopt-emule-identity and --import-downloads need --import-emule.
  • --webui-port, --webui-lan, --webui-host, --webui-proxy, --webui-api, --webui-guest-password-file and --webui-no-guest need --webui-password, --webui-password-file or --service=install; the last two not together.
  • --service comes alone, besides --log-level and, for install, the web interface options.

Exit codes​

CodeMeaning
0Done; for --check-update, this version is the newest; for --service=status, the service runs
1Failed: njMule could not start or connect, a download failed, no njMule answered, the check failed; for --service=status, the service does not run
2Usage error: an unknown option, a wrong value or a forbidden combination; the help follows the message
75Under systemd only: njMule has put a new version in place and stopped so that the service manager starts it again (Linux service)
100--check-update: a newer version is out

Environment variables​

VariableWhat it does
NJMULE_API_TOKENThe API token of the other njMule, for --remote-url (and for njmule-gui --remote-url, before the token of a connection it remembers)
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_CACHE_HOMELinux: where the configuration, data, logs and cache go, when set to an absolute path (njmule is the folder inside each)
XDG_DOWNLOAD_DIRLinux: the folder in which the completed downloads' folder njMule is made; otherwise the one of ~/.config/user-dirs.dirs, else ~/Downloads
NJMULE_INSTALL_KINDSet by the Docker image (docker), so that the update check tells to pull a new image; leave it alone

See Where njMule keeps its files for the folders on each system.