Python execute remote application using server resource
Question: I am trying to ran a matlab executable application from Python on a remote
server.

I used following code:

    
    
    os.system("\\Server-01\\D$\\matlab_t.exe 7.25 16")    # 7.25 and 16 are input arguments of matlab_t.exe
    

The above code is running on my local machine. I noticed that it is using
resources (CPU and memory) of my local machine, while I am trying to use
resources on the remote server.

May I know how I can execute it using server resource?

Thanks.


Answer: That command will run on your computer, the path may be pointing to a remote
server, but no one has told the remote server that it should execute code,
only that they need to serve the `matlab_t.exe` file.

You have to use a mechanism to access the remote server. Normally ssh is used
for this purpose, but the ssh daemon has to be running on the remote server
and also you need to have access (ask you admin about that).

Then you can use python like this:

    
    
    import paramiko
    
    ssh = paramiko.SSHClient()
    ssh.connect(server, username=username, password=password)
    ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd_to_execute_on_remote_server)
    

