-3

I have two devices one is Server and another one is Linux NODE. NODE does not have a python interpreter.

Server <------> NODE

I want to execute bash script remotely in the NODE triggered by Python program from the Server. And I should get the output of the bash script back to my Python script.

Pls. let me know how to do this.

Greenonline
  • 1,330
  • 8
  • 23
  • 31
  • What communication is possible between the two machines? What are the security restrictions (e.g. are you the admin of both machines)? Who is alllowed to run your program, and who should be allowed to remotely run the bash script? What user does the bash script need to run as? What software is already installed on the target server? Are you able to install additional software? Are both servers on the same network or could there be a firewall between them? You need to answer those questions before we can give you a reliable answer, or else the answers will be forced to guess. – Daniel Pryden Aug 18 '18 at 18:20
  • 1
    In case you're wondering why all the downvotes (I haven't, I appreciate that you're new here) https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/ – tink Aug 18 '18 at 19:35

1 Answers1

0

If you are able to SSH between the server and Node, then paramiko could be your answer. In your setup, it seems to me that you should be able to ssh.

Test it out by executing below command on server:

ssh node_user@node_name

Once you establish that ssh is available, you can run the below steps on server.

import paramiko
node='19.20.21.15'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(node,port=22,username='dummy',password='dummy')
stdin, stdout, stderr = ssh.exec_command("uname") # returns the OS type for example

This post has a very similar problem. Please revert back with the results.

ForeverLearner
  • 1,901
  • 2
  • 28
  • 51