Command-line flags activate various options when you launch Nuke from a shell, and provide additional functionality to Nuke. First let’s discuss how to launch Nuke from a shell.
Open a Terminal and change directory as follows:
cd /Applications/Nuke8.0v7/Nuke8.0v7.app/
To launch Nuke, type this command:
./Nuke8.0v7
Alternatively, you can set an alias to point to Nuke and then you can launch Nuke from any directory. The procedure for this depends on what your default shell is. To get the name of the shell you are using, launch Terminal and enter echo $SHELL.
If you are using a tcsh shell, enter:
alias nuke /Applications/Nuke8.0v7/Nuke8.0v7.app/Nuke8.0v7
(On 64-bit Nuke)
Alternatively, if you are using a bash shell enter:
alias nuke='/Applications/Nuke8.0v7/Nuke8.0v7.app/Nuke8.0v7'
(On 64-bit Nuke)
If you want to launch NukeX, enter:
alias nukex /Applications/Nuke8.0v7/NukeX8.0v7.app/NukeX8.0v7
(On 64-bit Nuke)
Change to your HOME directory:
cd
Launch Nuke:
nuke
TIP: You can add aliases to a .cshrc file (if you’re using a tcsh shell) in your home directory so that they are activated each time you open a shell. See your Systems Administrator for help setting this up.
If you’re on Mac OS X 10.5 or later, then your default shell is BASH and the file you need to edit is the .bash_profile file to add an alias to your home directory. Edit your .bash_profile to include this line:
alias nuke="/Applications/<your home directory>"
Note however that .bash_profile isn't read by bash in all cases. It's only read if bash is invoked as a login shell. Therefore it may be necessary to also add the alias to .bashrc.
To prevent two alias lists being kept in your system, you can create a file called .aliasrc with this line:
alias nuke="/Applications/<your Nuke directory>"
Then in both .bash_profile and .bashrc include the following line:
. .aliasrc
Now you can start experimenting with command line flags on launching Nuke. Here’s one that displays the version number and build date.
nuke -version
If you have a Nuke script, you can render it on the command line without opening the GUI version. Here’s an example that renders a hundred frames of a Nuke script:
nuke -F 1-100 -x myscript.nk
Note how you can use the -F switch on the command line to indicate a frame range, separating the starting and ending frames with a dash.
NOTE: We recommend that you use the new -F switch whenever defining a frame range on the command line, which must precede the script name argument.
However, for backwards compatibility, you can also use the old syntax in this release. To do so, place the frame range in the end of the command and use a comma to separate the starting and ending frames. For example:
nuke -x myscript.nk 1,100
For more information on defining frame ranges, see the Managing Scripts chapter of the Getting Started Guide.
To display a list of command line flags (switches) available to you, use the following command:
nuke -help
Here’s that list of command line flags in a table:
Switch/Flag |
Action |
-a |
Formats default to anamorphic. |
-b |
Background mode. This launches Nuke and returns control to the terminal, so you get your prompt back. This is equivalent to appending a command with an & to run in the background. |
--crashhandling 1 --crashhandling 0 |
Breakpad crash reporting allows you to submit crash dumps to The Foundry in the unlikely event of a crash. By default, crash reporting is enabled in GUI mode and disabled in terminal mode. Use --crashhandling 1 to enable crash reporting in both GUI and terminal mode. Use --crashhandling 0 to disable crash reporting in both GUI and terminal mode. |
-c size (k, M, or G) |
Limit the cache memory usage, where size equals a number in bytes. You can specify a different unit by appending k (kilobytes), M (megabytes), or G (gigabytes) after size. |
-d <x server name> |
This allows Nuke to be viewed on one machine while run on another. (Linux only and requires some setting up to allow remote access to the X Server on the target machine). |
-f |
Open Nuke script at full resolution. Scripts that have been saved displaying proxy images can be opened to show the full resolution image using this flag. See also -p. |
-F |
Frame numbers to execute the script for. All -F arguments must precede the script name argument. Here are some examples: • -F 3 indicates frame 3. • -F 1-10 indicates frames 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. • -F 1-10x2 indicates frames 1, 3, 5, 7, and 9. You can also use multiple frame ranges: nuke -F 1-5 -F 10 -F 30-50x2 -x myscript.nk |
-h |
Display command line help. |
-help |
Display command line help. |
-i |
Use an interactive (nuke_i) FLEXlm license key. This flag is used in conjunction with background rendering scripts using -x. By default -x uses a nuke_r license key, but -ix background renders using a nuke_i license key. |
-l |
New read or write nodes have the colorspace set to linear rather than default. |
-m # |
Set the number of threads to the value specified by #. |
-n |
Open script without postage stamps on nodes. |
--nocrashprompt |
When crash handling is enabled in GUI mode, submit crash reports automatically without displaying a crash reporter dialog. |
--nukeassist |
Launch Nuke Assist, which is licensed as part of a NukeX Maintenance package and is intended for use as a workstation for artists performing painting, rotoscoping, and tracking. Two complimentary licenses are included with every NukeX license. See the Meet the Nuke Product Family chapter in the Nuke Getting Started Guide for more information. |
-p |
Open Nuke script at proxy resolution. Scripts that have been saved displaying full resolution images can be opened to show the proxy resolution image using this flag. See also -f. |
-P |
Linux only. Measure your nodes’ performance metrics and show them in the Node Graph. |
--pause |
Initial Viewers in the script specified on the command line should be paused. |
--ple |
Runs Nuke in Personal Learning Edition mode. |
--priority p |
Runs Nuke with a different priority, you can choose from: • high (only available to the super user on Linux/OS X) • medium • low |
--python-no-root-knobdefaults |
Prevents the application of knob defaults to the root node when executing a Python script. |
-q |
Quiet mode. This stops all printing to the shell. |
-remap |
Allows you to remap file paths in order to easily share Nuke projects across different operating systems. This is the command-line equivalent of setting the Path Remaps control in the Preferences dialog. The -remap flag takes a comma-separated list of paths as an argument. The paths are arranged in pairs where the first path of each pair maps to the second path of each pair. For example, if you use: nuke -t -remap "X:/path,Y:,A:,B:/anotherpath" • Any paths starting with X:/path are converted to start with Y:. • Any paths starting with A: are converted to start with B:/anotherpath. The -remap flag throws an error if: • it is defined when starting GUI mode, that is, without -x or -t. • the paths do not pair up. For example, if you use: nuke -t -remap "X:/path,Y:,A:" A: does not map to anything, and an error is produced. The -remap flag gives a warning (but does not error) if you give it no paths. For example: nuke -t -remap "" NOTE: Note that the mappings are only applied to the Nuke session that is being started. They do not affect the Preferences.nk file used by the GUI. |
-s # |
Sets the minimum stack size, or the node tree stach cache size for each thread in bytes. This defaults to 16777216 (16 MB). The smallest allowed value is 1048576 (1 MB). |
--safe |
Running Nuke in this mode stops the following loading at startup: • Any scripts or plug-ins in ~/.nuke • Any scripts or plug-ins in $NUKE_PATH or %NUKE_PATH% • Any OFX plug-in (including FurnaceCore) |
--sro |
Forces Nuke to obey the render order of Write nodes so that Read nodes can use files created by earlier Write nodes. |
-t |
Terminal mode (without GUI). This allows you to enter Python commands without launching the GUI. A >>> command prompt is displayed during this mode. Enter quit() to exit this mode and return to the shell prompt. This mode uses a nuke_r license key by default, but you can get it to use a nuke_i key by using the -ti flag combo. |
--tg |
Terminal Mode. This also starts a QApplication so that Pyside/PyQt can be used. This mode uses an interactive license, and on Linux requires an X Windows display session. |
-V level |
Verbose mode. In the terminal, you’ll see explicit commands as each action is performed in Nuke. Specify the level to print more in the Terminal, select from: • 0 (not verbose) • 1 (outputs Nuke script load and save) • 2 (outputs loading plug-ins, Python, TCL, Nuke scripts, progress and buffer reports) |
-v |
This command displays an image file inside a Nuke Viewer. Here’s an example: nuke -v image.tif |
--view v |
Only execute the specified views. For multiple views, use a comma separated list: • left,right |
--version |
Display the version information in the shell. |
-x |
eXecute mode. Takes a Nuke script and renders all active Write nodes. Note that it is not possible to render a PLE (Personal Learning Edition) script with -x from the command line, that is, using the syntax: nuke -x myscript.nk Note also that this mode uses a FLEXlm nuke_r license key. To use a nuke_i license key, use -xi. This is the syntax: nuke -xi myscript.nk On Windows, you can press Ctrl+Break to cancel a render without exiting if a render is active, or exit if not. Ctrl/Cmd+C exits immediately. On Mac and Linux, Ctrl/Cmd+C always exits. |
-X node |
Render only the Write node specified by node. |
-- |
End switches, allowing script to start with a dash or be just - to read from stdin |
This is the general syntax for using these options when launching Nuke at the command prompt:
nuke <switches> <script> <argv> <ranges>
<switches> - modifies the behavior of Nuke when run from the command line. A list of switches is given in the table above. These are sometimes called flags.
<script> - the name of the Nuke script.
<argv> - an optional argument that can be used in Nuke. See the example below.
<ranges> - this is the frame range you want rendering.
Let’s consider some practical examples.
To launch Nuke and open a script.
nuke myscript.nk
Crazy I know, but I’ve called my script, -myscript.nk, and the hyphen at the start of the filename has confused Nuke. To get round this if you don’t want to rename your file use the double hyphen syntax:
nuke -- -myscript.nk
To display an image:
nuke -v polarbear.tif
To display several images:
nuke -v polarbear.tif whiteflower.psd mountains.cin
To display an image sequence (taxi.0001.tif, taxi.0002.tif,...,taxi.0050.tif):
nuke -v taxi.####.tif 1-50
To render frame 5 of a Nuke script:
nuke -F 5 -x myscript.nk
To render frames 30 to 50 of a Nuke script:
nuke -F 30-50 -x myscript.nk
To render two frame ranges, 10-20 and 34-60, of a Nuke script:
nuke -F 10-20 -F 34-60 -x myscript.nk
To render every tenth frame of a 50 frame sequence of a Nuke script:
nuke -F 1-50x10 -x myscript.nk
This renders frames 1, 11, 21, 31, 41.
In a script with two write nodes called WriteBlur and WriteInvert this command just renders frames 1 to 20 from the WriteBlur node:
nuke -X WriteBlur myscript.nk 1-20
Let’s use [argv] to vary the output file name. Launch the GUI version of Nuke and create a node tree that puts a checker into a Write node. Open the write node property panel by double clicking on it and in the file text field enter this filename:
[argv 0].####.tif
Save the script and quit Nuke. On the command line type:
nuke -x myscript.nk mychecker 1-5
This renders 5 frames (mychecker.0001.tif, mychecker.0002.tif, etc.).
You can add another variable to control the output image file type. The file text field needs this:
[argv 0].####.[argv 1]
and then render the script using this command:
nuke -x myscript.nk mychecker cin 1-5
to get mychecker.0001.cin, mychecker.0002.cin, etc.
The <argv> string can be any [argv n] expression to provide variable arguments to the script. These must be placed between the <script> and the <ranges> on the command line. You can include multiple expressions, but each must begin with a non-numeric character to avoid confusion with the frame range control. For more information on expressions, see Expressions.
This command line method converts 5 TIFF frames to JPEG.
nuke -t
>>> r = nuke.nodes.Read(file = ”myimage.####.tif”)
>>> w = nuke.nodes.Write(file = ”myimage.####.jpg”)
>>> w.setInput( 0, r )
>>> nuke.execute(“Write1”, 1,5)
>>> quit()
It’s a bit tedious typing these commands in line by line. So let’s put them in a text file called imageconvert.py and get Nuke to execute the Python script.
cat imageconvert.py
r = nuke.nodes.Read(file = ”myimage.####.tif”)
w = nuke.nodes.Write(file = ”myimage.####.jpg”)
w.setInput( 0, r )
nuke.execute(“Write1”, 1,5)
nuke -t < imageconvert.py
You can also pass in the Python script as a command line parameter. Doing this allows you to enter additional parameters after the script name to pass into your script. When you do so, note that sys.argv[0] is the name of the Python script being executed, and argv[1:] are the other parameters you passed in. One example of this is below. See the standard Python module optparse for other ways to parse parameters.
cat imageconvertwithargs.py
import sys
r = nuke.nodes.Read(file = sys.argv[1])
w = nuke.nodes.Write(file = sys.argv[2])
w.setInput(0, r)
nuke.execute("Write1", 1, 5)
nuke -t imageconvertwithargs.py myimage.####.tif myimage.####.jpg