AWS Thinkbox Discussion Forums

Command line tool return non-0 value for success - robocopy

Hi,

Apologies in advance if this is a RTFM question, but is there a way to work with command line tools that don’t return standard values, i.e. 0 is success. I need to sync a bunch of data using a PC, so robocopy is involved. Robocopy returns 0 if nothing was done and 1 for a successful transfer. 2, 4, 8 and 16 indicate other things. As of now, each job runs twice. The first time, the transfer happens and robocopy returns 1. Deadline sees a failed job and requeues. The second time around, robocopy sees that it doesn’t have to do anything and returns 0.

Work is getting done, but it’s not ideal. Any pointers or advice would be appreciated.

HP

Reference on the robocopy exit codes
https://ss64.com/nt/robocopy-exit.html

If you’re using “Submit Command Line Job To Deadline” then what you could do is copy the whole folder from “//YOUR_REPO/plugins/CommandLine” to //YOUR_REPO/custom/plugins/CommandLine" so as to make a custom version of the plugin that you can then modify.
(This will override the standard plugin. To disable the custom version just remove the folder from the “…/custom/plugins/”.)

In the folder you have CommandLine.py python file, you want to modify function called RenderTasks at line 71 that says:

        if exitCode != 0:
            self.FailRender( "Process returned non-zero exit code '{}'".format( exitCode ) )

to:

        if exitCode != 0 and exitCode != 1:
            self.FailRender( "Process returned non-zero exit code '{}'".format( exitCode ) )

No bear in mind that this will also affect all other command line jobs, so if they fail with code 1 the new custom command line plugin won’t catch them.

If you’re handy with python then you could make aversion that recognizes the robocopy and only uses the exitcode 1 for that.

1 Like

The proper way would be to create a RobocopyPlugin, which inherits from CommandLinePlugin and only overrides RenderTasks (I guess) to achieve the desired behaviour.

I ran into the same difficultly today…

I didn’t want to modify the CommandLinePlugin (as most of our usage of it relies on non-zero exit codes failing tasks). Creating a RobocopyPlugin would definitely be a better solution, but as this was a one-off thing, a simpler solution was to handle this as a batch-script,

I.e submitting a CommandLinePlugin job with command set to

C:\WINDOWS\system32\cmd.exe

and the args set to something like:

/C (robocopy "c:\dirA" "c:\dirB") ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0

…based on https://superuser.com/a/346112

1 Like
Privacy | Site terms | Cookie preferences