Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. client.exec_command('/apps./tempo.sh' 2016 10 01 02 03))
  2.  
  3. import sys
  4. client.exec_command('/apps./tempo.sh', str(sys.argv))
  5.  
  6. client.exec_command('/apps./tempo.sh %s' % str(sys.argv))
  7.  
  8. import paramiko
  9. ssh_client = paramiko.SSHClient()
  10. ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  11. ssh_client.connect(server, username=user,password=password)
  12. ...
  13. ssh_client.close()
  14.  
  15. chan=ssh_client.invoke_shell()
  16. chan.send('PS1="python-ssh:"n')
  17.  
  18. def exec_command(cmd):
  19. """Gets ssh command(s), execute them, and returns the output"""
  20. prompt='python-ssh:' # the command line prompt in the ssh terminal
  21. buff=''
  22. chan.send(str(cmd)+'n')
  23. while not chan.recv_ready():
  24. time.sleep(1)
  25. while not buff.endswith(prompt):
  26. buff+=ssh_client.chan.recv(1024)
  27. return buff[:len(prompt)]
  28.  
  29. import sys
  30.  
  31. command = '/apps./tempo.sh'
  32. args = ' '.join(sys.argv[1:]) # all args except the script's name!
  33. client.exec_command('{} {}'.format(command, args))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement