Q100481: How to redirect Nuke's command line output to a text file

Warning:  This article contains links to external websites

SUMMARY

The following article explains how to redirect Nuke’s standard output and standard error output to a file.

MORE INFORMATION

Nuke’s command line operations are outputted as Standard Streams, which are split into Standard Input (STDIN), Standard Out (STDOUT) and  Standard Error (STDERR).

Exporting Nuke’s command line output as a separate file allows the user to review these standard streams after the application has closed for custom plugin locations, rendering speed or information outputted by the Script Editor.

By executing Nuke in a Command Prompt (Windows) or terminal (Mac/Linux), you can redirect the command line output to a file using the ‘ > ’ symbolThis is used as a Redirection of Standard Streams to user-specified locations.

In order to redirect the STDOUT and STDERR streams, the command line operation needs to specify the File Descriptors of each stream, before the redirection symbol. The default file descriptor for the STDOUT stream is ‘1’ and for the STDERR stream is ‘2’.

The command line operation provided below shows an example of STDOUT and STDERR output redirection  to different text files saved on the desktop:

Windows:

"C:\Program Files\Nuke11.3v2\Nuke11.3.exe" -V 1> C:\Users\USERNAME\Desktop\stdout.txt 2> C:\Users\USERNAME\Desktop\stderr.txt

Mac:

/Applications/Nuke11.3v2/Nuke11.3v2.app/Contents/MacOS/Nuke11.3v2 -V 1> /Users/USERNAME/Desktop/stdout.txt 2> /Users/USERNAME/Desktop/stderr.txt

Linux:

'/usr/local/nuke11.3v2/Nuke11.3' -V 1> /home/USERNAME/Desktop/stdout.txt 2> /home/USERNAME/Desktop/stderr.txt

 
NOTE: Replace USERNAME with your machine user name.

There are a few things to highlight about the example commands provided above:

  • Redirecting the command line output will no longer display any information within the Command Prompt/terminal, as all the data is being redirected to the text file.
  • Adding the '-V' verbose command line flag will include everything that Nuke loads by default and can be useful in diagnosing plugin issues.

    For more information on verbose mode, please refer to this article: Q100112: Launching Nuke in verbose mode and isolating potential customisations causing issues
  • You will need to add --nukex, --studio or --hiero to the command line example above in order to launch NukeX, Nuke Studio or Hiero as appropriate.

Both the standard output and standard error output can be redirected together to a single file by using the ‘&’ symbol.

Below is an example command for each OS:

Windows:

"C:\Program Files\Nuke11.3v2\Nuke11.3.exe" -V C:\Users\USERNAME\Desktop\stdout.txt> 

Mac:

/Applications/Nuke11.3v2/Nuke11.3v2.app/Contents/MacOS/Nuke11.3v2 -V 1> /Users/USERNAME/Desktop/stdout.txt 2>&1

Linux:

'/usr/local/nuke11.3v2/Nuke11.3' -V 1> /home/USERNAME/Desktop/stdout.txt 2>&1

Merging both streams together provides the benefit of keeping all outputted data in the same file, and looks similar to the output typically displayed in the Command Prompt/terminal.

FURTHER READING

For more information on Nuke command line flags, please refer to our documentation: Nuke Online Help - Command Line Operations