Guest User

Untitled

a guest
Aug 27th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. multiprocess module with paramiko
  2. jobs = []
  3. for obj in appObjs:
  4. if obj.stop_app:
  5. p = multiprocessing.Process(target=exec_cmd, args=(obj, obj.stop_cmd))
  6. jobs.append(p)
  7. print "Starting job %s" % (p)
  8. p.start()
  9.  
  10. raise AssertionError("PID check failed. RNG must be re-initialized after fork().
  11. Hint: Try Random.atfork()")
  12.  
  13. import ssh
  14. from multiprocessing import Process
  15.  
  16. handle = ssh.SSHClient()
  17. handle.set_missing_host_key_policy(ssh.AutoAddPolicy())
  18. handle.connect(hostname, username=user, password=pass)
  19.  
  20. def processFunc(param):
  21. print "child"
  22. stdin, stdout, stderr = handle.exec_command("ls -l /var/log")
  23. cmdOutput = ""
  24. while True:
  25. try:
  26. cmdOutput += stdout.next()
  27. except StopIteration:
  28. break
  29. print cmdOutput
  30.  
  31. dummy = None
  32. p = Process(target=processFunc, args=(dummy,))
  33. p.start()
  34. p.join()
  35.  
  36. print "Parent"
  37. processFunc(dummy)
  38.  
  39. handle.close()
Add Comment
Please, Sign In to add comment