How to use paramiko to send multiple commands to the switch and receive a long output?

1. You need to use the paramiko module to send two commands to the switch. The first "screen-length disable" is used to cancel the single-screen echo, and the second" display cur" is used to output the contents of the configuration file. There are two existing problems: a channel of
1paramiko can only receive one command, and then channel shuts down. These two commands need to be sent under a connection.
2 the echo of the second command is very long (about 5000 lines), and it will stutter when you use the readlines () method, with no output and no exception.
my code is as follows:

1   import paramiko                                                                                                                           
  1 import datetime
  2      
  3 time1 = datetime.datetime.now()
  4 time2 = time1.strftime("%Y-%m-%d")
  5      
  6 def ssh2(ip, username, passwd, cmd):
  7     try:
  8         ssh = paramiko.SSHClient()
  9         ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 10         ssh.connect(ip, 22, username, passwd, timeout=10)
 11         for m in cmd:
 12             stdin, stdout, stderr = ssh.exec_command(m)
 13             out = stdout.readlines()
 14             for o in out:
 15                 print(o)
 16         print("%s\tOK\n"%(ip))
 17         ssh.close()
 18     except Exception as e:
 19         print("%s\tError\n"%(ip))
 20         print(e)
 21      
 22      
 23      
 24 if __name__ == "__main__":
 25     ssh2("10.74.49.61", "g-netops@system", "1qaz2wsxQWER", ["screen-length disable", "dis cur"])
~                                                                                                          

the output is as follows:

seek a solution, thank you!

Mar.13,2021
Menu