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?
The code below will do what you want and you can adapt it to your
execute
function:Note, though, that commands will default to your
$HOME
directory, so you'll either need to haveinstall.sh
in your$PATH
or (most likely) you'll need tocd
to the directory that contains theinstall.sh
script.You can check your default path with:
However, if it is not in your path you can
cd
and execute the script like this:If the script is not in your
$PATH
you'll need to use./install.sh
instead ofinstall.sh
, just like you would if you were on the command line.If you are still having problems after everything above it might also be good to check the permissions of the
install.sh
file, too:See the
subprocess
module.