I'm trying to use paramiko to connect and execute a remote script. In the below code, should the script in the client.exec_command can contain only linux commands (like ls -l)?
Code in Ubuntu BOX A:
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('ip-address of Ubuntu BOX B',22,'username','password') <<<<< no issues till here....
stdin, stdout, stderr = client.exec_command('./shut.sh')
for line in stdout:
print 'This is the normal value ==> ' + line.strip('\n')
for line in stderr:
print 'This is the err value ==> ' + line.strip('\n')
client.close()
When I run the above code, I get "awsstop command not found".
My remote script(shut.sh) contains ZPDT shutdown command, where I shutdown my zpdt system.
shut.sh in Ubuntu Box B
#!/bin/sh
awsstop
However, when I run the shut.sh locally thru the below python code, it works as expected.
test.py in Ubuntu Box B
import os
import subprocess
subprocess.Popen(["/home/ibmsys1/shut.sh"])
Is there anyway, we can trigger this script remotely OR Is it that, paramiko is not capable of doing this ? Do we have any other option ?