0

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.

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

0

In python, the os.system command only executes the command on the local machine. What you want is a local command that will get the server to execute it by itself.

If the server is Windows based then you can use PsExec to do this, if the server is Linux based then using ssh with a python library (like the other answer demonstrates) would probably be the way to go.

Using PsExec, your command in os.system would be something like:

psexec.exe \\Server-01 -u <username> -p <password> D:\matlab_t.exe 7.25 16

If you server needed no authentication, you could remove the username and password flags.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.