Created
July 18, 2016 00:18
-
-
Save robla/28a322a1ad73cb16b9e6edc8bc70a484 to your computer and use it in GitHub Desktop.
print the sftp URL of a file from shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import socket | |
import sys | |
import urllib | |
def sftppath(file): | |
fqdn=socket.getfqdn() | |
fullpath=os.path.realpath(os.path.expanduser(file)) | |
return "sftp://" + fqdn + urllib.quote(fullpath) | |
if len(sys.argv)>1: | |
for arg in sys.argv[1:]: | |
print sftppath(arg) | |
else: | |
print sftppath(".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment