Paramiko capturing command output

前端 未结 3 1062
抹茶落季
抹茶落季 2020-12-22 06:37

I have an issue that has been giving me a headache for a few days. I am using the Paramiko module with Python 2.7.10 and I\'d like to issue multiple commands to a Brocade ro

3条回答
  •  Happy的楠姐
    2020-12-22 07:04

    If you can, the exec_command() call provides a simpler mechanism to invoke a command. I have seen Cisco switches abruptly drop connections that try exec_command(), so that may not be usable with Brocade devices.

    If you must go the invoke_shell() route, be sure to clear all pending output after connecting and after send('terminal length 0\n'), checking recv_ready() before calling recv() to avoid blocking on reading data that might not ever arrive. Since you are controlling an interactive shell, sleep() calls might be needed to allow the server adequate time to process and send data, or it might be necessary to poll the output string to confirm that your last command completed by recognizing the shell prompt string.

提交回复
热议问题