diff --git a/util/zotsh/README.txt b/util/zotsh/README.txt index 4238a4850..92bc55411 100644 --- a/util/zotsh/README.txt +++ b/util/zotsh/README.txt @@ -24,6 +24,10 @@ The ability to browse remote WebDAV repositories outside your own server is not cd username +OR you can connect to the site using + +host username@hostname + if you know a username on that site and if they have given you the requisite permission *or* their directory contains publicly readable content. ---- @@ -41,10 +45,12 @@ Commands host Authenticate to 'hostname' and switch to it +host + Authenticate to 'hostname' and switch to it and automatically cd to the 'username' directory + cd change remote dir - ls [path] [-a] [-l] [-d] list remote files in current dir if 'path' not defined -a list all, show hidden dot-files diff --git a/util/zotsh/zotsh.py b/util/zotsh/zotsh.py index 867c24ab6..0cfde6edf 100755 --- a/util/zotsh/zotsh.py +++ b/util/zotsh/zotsh.py @@ -141,9 +141,15 @@ class ZotSH(object): return self.davclient.download(args[0], args[1]) def cmd_host(self, *args): + ruser = '' if (len(args)==0): return newhostname = args[0] + i = newhostname.find('@') + if (i != (-1)): + ruser = newhostname[0:i] + newhostname = newhostname[i+1:] + newhost = "https://%s/" % newhostname if newhostname == "~" or newhost == SERVER: # back to home server @@ -165,7 +171,13 @@ class ZotSH(object): self.hostname = newhostname self.session = session_remote - + + if (ruser): + try: + self.do('cd', *[ruser]) + except easywebdav.client.OperationFailed as e: + print(e) + def cmd_pwd(self, *args): return "%s%s" % ( self.davclient.baseurl, self.davclient.cwd )