I'm new to python paramiko. I know there are two ways to execute a command in a remote server invokde_shell
and exec_command
. In few cases the output is read using stdout.readlines()
whereas in other cases using channel.recv
with exit_status
as loop condition. It is very difficult to understand the difference between both and which one to use for my script. Can anyone please explain ?
Asked
Active
Viewed 1,201 times
1

Martin Prikryl
- 188,800
- 56
- 490
- 992

Chandru Jc
- 105
- 10
1 Answers
1
This is rather broad question, so only briefly:
readlines
vs recv
– This is nothing Paramiko-specific. You have the same set of functions, when reading local files or local program input. Use whatever fits your needs. If you need to read by bytes (e.g. when processing a binary input), you probably want to use recv
(or read
). If you want to process a textual input by lines, use readlines
(or readline
).
You also mix in shell vs. exec into your question, what is a separate stuff, covered here:
What is the difference between exec_command and send with invoke_shell() on Paramiko?
Overall, you better ask a specific question about implementing your specific problem.

Martin Prikryl
- 188,800
- 56
- 490
- 992