Alex Rivera | Logout

How to execute a script remotely in Python using SSH?

Asked 2012-01-09T01:26:39.090
9
def execute(self,command):
            to_exec = self.transport.open_session()
            to_exec.exec_command(command)
            print 'Command executed'
connection.execute("install.sh")

When I check the remote system, I found the script didn't run. Any clue?

Edit
Report

1 Answer

-3
subprocess.Popen('ssh thehost install.sh')

See the subprocess module.

answered 2012-01-09T01:33:43.130

Your Answer