python - SSHClient.exec_command() reported "command not found" -
i've written script others run simple day day commands on our storage system here @ work. script works fine commands return short , simple output, example, ls, however, when script wants run command has large output, output isn't returned. it's if times out there's no feedback @ all, e.g. thought there might part of command output. i've done research around , discovered other people same problem. answers got use:
stdin, stdout, stderr = client.exec_command(command)
which using in code. i'm wondering if it's buffer size, annoyingly don't know how implement in code. i've tried adding time delay using:
time.sleep(10)
but no joy that. have tried using:
print stdout.channel.recv_exit_status()
however, got return of 127 think i'm way off mark there! code is:
def ssh_command(ip, user, passwd, command): client = paramiko.sshclient() client.set_missing_host_key_policy(paramiko.autoaddpolicy()) client.connect(ip, username=user, password=passwd) stdin, stdout, stderr = client.exec_command(command) print stdout.read() print stderr.read() return if __name__ == '__main__': ssh_command(ip, user, passwd, command)
i've omitted first few blocks of code few variables defined raw input user. it's rather long thought best omit naturally, can post if needs be.
for interested in command i'm trying run, it's ibm command unique gpfs (spectrum scale) storage system. command is:
mmdf mmfs1 --block-size auto
the command returns storage space on disk pools on storage system.
update:
the stderr.read()
states command isn't recognised (bash: mmdf: command not found
) despite working when ssh'd storage controller.
based on latest comments should use absolute path mmdf
when running command:
client.exec_command("/the/path/to/mmdf mmfs1 --block-size auto")
to find out mmdf
is, manually login server , run:
which mmdf # or type -p mmdf
Comments
Post a Comment