Control Deadline Slave 'AfterTask' from deadlinecommand?

I’m trying to figure out how to set a slave to ‘Stop after current task completion’. The only way I’ve found to do it so far is.

C:\Program Files\Thinkbox\Deadline7\bin\deadlineslave.exe -aftertask StopSlave

But how can I get that to run on a targeted Deadline Slave when I run a python script using deadlinecommand? Is there a way to use the ‘ExecuteCommand’ function that’s in the Deadline Monitor?

A few more questions.
Can I get the number of deadline licenses through the API? Either Total or In-Use?
If I need to query all the Slaves at once to get their % complete, Total Ram and status what’s the most efficient way to do this?

Thanks

Dave

Oh boy. Lots of questions!

For “after current task completion” us the “RemoteControl” from deadlinecommand. It’s using the same code as the “Remote Control” menu in the Slave list.

deadlinecommand remotecontrol [machine name] OnLastTaskComplete ShutdownMachine

Here’s the list from the help text of dlc:

RemoteControl
  Send the remote command to the Deadline Launcher running on the specified
  machine(s).
    [Machine Name(s)]        The machine name, or a list of machine names
                             separated by commas.
    [Remote Command]         The remote command. The available commands are
                             StopLauncher, LaunchSlave, LaunchAllSlaves,
                             LaunchNewSlave, RemoveSlave, LaunchSlaveDelay,
                             StopSlave, RelaunchSlave, ForceStopSlave,
                             ForceRelaunchSlave, OnLastTaskComplete,
                             LaunchPulse, StopPulse, RestartPulse,
                             RemotePulseCommand, LaunchProxyServer,
                             StopProxyServer, RestartProxyServer,
                             LaunchBalancer, StopBalancer, RestartBalancer,
                             RemoteBalancerCommand, LaunchMonitor,
                             StopMonitor, StopConfig, RestartMachine,
                             StartMachine, ShutdownMachine, Execute,
                             ExecuteNoWait
    [Argument]               The argument for LaunchSlave, LaunchNewSlave,
                             and RemoveSlave is the name of the Slave. The
                             argument for Execute and ExecuteNoWait is the
                             command to execute. Valid arguments for
                             OnLastTaskComplete are Continue, StopSlave,
                             RestartSlave, CheckForTasks, CancelTask,
                             ClearFailureCache, ShutdownMachine [comment] and
                             RestartMachine [comment]. [comment] is a message
                             that can be sent to explain why the shutdown or
                             restart machine command was executed. It will be
                             recorded in the machines event log. Valid
                             arguments for RemotePulseCommand are
                             HouseCleaning, PendingJobScan, RepositoryRepair,
                             and PowerManagement. Valid arguments for
                             RemoteBalancerCommand are Balancing.

On the license front, Deadline actually has no awareness of how many licenses are available. It just knows when it can’t get one. You’d have to use the usual FlexLM tools for that like lmutil lmstat -S thinkbox -a

For the Slave info, this one:

deadlinecommand getslaves true

Thanks Edwin, not sure how I missed that in the docs, but certainly does what I need it to thanks!