Guest User

Untitled

a guest
Dec 11th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import os, sys
  3. import subprocess
  4.  
  5. HOST_MOUNT_DIR = '\$HOME/ubuntu'
  6.  
  7. # get the ip of the host
  8. host = os.environ['SSH_CLIENT'].split(' ')[0]
  9.  
  10. # get the path from $HOME to the file
  11. file_path = os.path.relpath(os.path.abspath(sys.argv[1]),
  12. os.path.expanduser('~'))
  13.  
  14. # get the path from to the file on the host filesystem
  15. remote_path = os.path.join(HOST_MOUNT_DIR, file_path)
  16.  
  17. # we're going to use the default editor on the host
  18. args = '/usr/bin/ssh %s "\$EDITOR %s"' % (host, remote_path)
  19. print args
  20. subprocess.Popen(args, shell=True)
Add Comment
Please, Sign In to add comment