Go to: Synopsis. Return value. Flags. MEL examples.
cmdFileOutput [-close uint] [-closeAll] [-open string] [-status uint]
cmdFileOutput is undoable, queryable, and NOT editable.
This command will open a text file to receive all of the commands and results that normally get printed to the Script Editor window or console. The file will stay open until an explicit -close with the correct file descriptor or a -closeAll, so care should be taken not to leave a file open.To enable logging to commence as soon as Maya starts up, the environment variable MAYA_CMD_FILE_OUTPUT may be specified prior to launching Maya. Setting MAYA_CMD_FILE_OUTPUT to a filename will create and output to that given file. To access the descriptor after Maya has started, use the -query and -open flags together.
| int | : On open, returns a value (descriptor) that can be used to query the status or close the file. Otherwise, a status code indicating status of file |
In query mode, return type is based on queried flag.
| Long name (short name) | Argument types | Properties | ||
|---|---|---|---|---|
-close(-c)
|
uint
|
|
||
|
||||
-closeAll(-ca)
|
|
|
||
|
||||
-open(-o)
|
string
|
|
||
|
||||
-status(-s)
|
uint
|
|
||
|
||||
cmdFileOutput -o "dbOutput.txt";
// Result: 1 //
print "This message is in the file\n";
// This message is in the file
cmdFileOutput -s 1;
// Result: 0 //
cmdFileOutput -s 2;
// Result: -3 //
cmdFileOutput -c 1;
// Result: 0 //
// Notice that the 'This message is in the file' string is in the file,
// as are all of the entered commands and the
// '// Result: ...' lines, etc.
// Turn on logging to a file on Maya startup so as to log all error
// messages which happen on startup.
//
// Set the environment variable MAYA_CMD_FILE_OUTPUT to "trace.txt"
// Start up Maya
// Messages should now be logged to the file "trace.txt" as well as the
// script editor window.
// Turn off logging to the filename specified by $MAYA_CMD_FILE_OUTPUT
// after Maya has completed startup.
//
string $traceFile = getenv( "MAYA_CMD_FILE_OUTPUT" );
int $descriptor = `cmdFileOutput -o $traceFile -q`;
if ( -1 != $descriptor ) {
cmdFileOutput -close $descriptor;
}
// Result: 0 //