Guest User

Untitled

a guest
Apr 10th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import paramiko
  2. from threading import Thread
  3. from time import sleep
  4.  
  5. l_password = "passwordofPi"
  6. l_host = "192.168.2.3"
  7. l_user = "pi"
  8.  
  9.  
  10. ssh = paramiko.SSHClient()
  11. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12. ssh.connect(l_host, username=l_user, password=l_password)
  13. transport = ssh.get_transport()
  14. session = transport.open_session()
  15. session.set_combine_stderr(True)
  16. session.get_pty()
  17. session.exec_command("nohup lora_gateway/libloragw/test_loragw_hal -a 868.6 -b 868.9 -t 850 -r 1257 > log.txt & ")
  18. stdin = session.makefile('wb', -1)
  19. stdout = session.makefile('rb', -1)
  20.  
  21. stdin.write(l_password +'n')
  22. stdin.flush()
  23. for line in stdout.read().splitlines():
  24. print ('host: %s: %s' % (l_host, line))
  25.  
  26. if ssh is not None:
  27. ssh.close()
  28. ssh = None
Add Comment
Please, Sign In to add comment