How to execute python command on slave machine thru Remote Administration

In sendRemoteCommand(slave,"Execute cmd /C copy c:\myfile.txt d:\myfile.txt)

Can we use python commands as well to do the same at remote machine…?

Can someone let me know…

Thanks

Would a Python job handle what you’re looking to do?

Thanks for ur reply

I tried placing python portable in shared location and given exe path to plugins … submitted python job with script and works fine

I have issue with ‘|’ or operator in command string…

PFL below example code to execute at remote pc.When i run this, it gives me error, cannot recognize the command “find”.What ever comes after this symbol ‘|’ will be shown as error in console. I see it is because of ‘|’ or operator in the command which is giving me the error. I tried to escape using ‘|’ but no luck. can someone please let me know how to resolve this issue.

codeToRun =r"Execute cmd /C tasklist /FI “IMAGENAME eq myapp.exe” 2>NUL | find /I /N “myapp.exe”>NUL & if “%ERRORLEVEL%”==“0” echo Program is running"

SlaveUtils.SendRemoteCommand(slaveName,codeToRun )

If you don’t want to both with Python portable, you can use the Python that Deadline packages and uses, called dpython. You’ll see it in your Deadline install directory called dpython.exe, and you could add it to one of the version paths under Tools->Configure Plugins->Python.

If you run the command you’re using there at the prompt of the target machine do you get the same issue? Or only when you’re running it via Deadline?

As you said, i have put a portable python in shared location and i have 2 files now.

  1. ToRun.py (this script have to Run from local machine)
    2.Render_Ae.py (this is deadline UI script)

So, i have to run Render_Ae.py by Right clicking on slave,Get slaveinfo etc… and finally i have to
trigger ToRun.py using sendRemoteCommand(machine, command) so that toRun.py runs from remote machine.

Below is the code to trigger
#sample code
pythonPath=r"\winupdatesrv\DeadlineRepository10\plugins\Python\python36\python.exe"
scriptToRunpath=r"\winupdatesrv\DeadlineRepository10\custom\scripts\General\ToRun.py"
Argument1 = r"\EDITINGPC-71\Shared\Comp 1\comp1.aep"

SlaveUtils.SendRemoteCommand(machinename,“Execute cmd /C “”+pythonPath+”"" “”+scriptToRunpath+"" “”+Argument1 +""")

This above code cannot run script and gives out error saying cannot find path & Cannot recognize command etc…

Please let me know the problem.

Hello!

What’s the error specifically? Which file is it failing to find?

If you run that command on the machine locally does it succeed?

Yes, running locally by putting code in notepad.bat works fine.
deadline not specifically mentioning which path.
Ok, please ignore the above mentioned code and all.
i just want to know one small thing.rest i will try to fix. How to run python script from command line?

pythonPath=r"\winupdatesrv\DeadlineRepository10\plugins\Python\python36\python.exe"
scriptToRunpath=r"\winupdatesrv\DeadlineRepository10\custom\scripts\General\ToRun.py"

How do you run it using sendRemoteCommand(machine, "Execute cmd /c ")

please give me the syntax for the above.

Thanks

Something like:

pythonPath=r"\winupdatesrv\DeadlineRepository10\plugins\Python\python36\python.exe"
scriptToRunpath=r"\winupdatesrv\DeadlineRepository10\custom\scripts\General\ToRun.py"

command = r"Execute " + " " + pythonPath + " " scriptToRunpath

SlaveUtils.SendRemoteCommand("MachineName", command)

My local install is in a bit of a bad state so that should work, though I haven’t seen any of the error messages you’re getting. It’s essentially what you’re already doing as without the error message I don’t know what I’m fixing.

1 Like

Thank you…
I want to know syntax only…rest I ll figure it out Justin

It’s working fine now…

Thank you