summaryrefslogtreecommitdiff
path: root/ftp-get.py
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-12 16:20:11 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-08-12 16:20:11 +0200
commit98d5f7c43312e5cba33d7dca38b3fcffc10cd645 (patch)
treecb0b5837983e40584df0541a27d3b3639ca51d2b /ftp-get.py
parenteeb5f89ba0000edf6a5480a38ff6fca958c4ef32 (diff)
downloadscripts-98d5f7c43312e5cba33d7dca38b3fcffc10cd645.tar.gz
ftp: ignore ms in mlsd, process path in ftp-get
- ftp-get: when 'get bar.ext' on ftp.example.com/foo/, the directory 'foo' won't be created.
Diffstat (limited to 'ftp-get.py')
-rwxr-xr-xftp-get.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ftp-get.py b/ftp-get.py
index c3da943..c7e6fab 100755
--- a/ftp-get.py
+++ b/ftp-get.py
@@ -48,7 +48,10 @@ if len(sys.argv) >= 2:
port = int(m.group("port"))
if m.group("path") is not None:
path = m.group("path")
- print("Warning: path component is ignored", file=sys.stderr)
+ if not path.endswith("/"):
+ print("Path must be a directory",
+ file=sys.stderr)
+ sys.exit(1)
if host is None:
print("Usage: python", sys.argv[0],
@@ -59,11 +62,11 @@ if host is None:
files = []
for line in sys.stdin:
- file_path = line.rstrip("\r\n")
+ file_path = line.rstrip("\r\n").lstrip("/")
# note: os.path.join(outdir, file_path) throws away if file_path
# is absolute. That is *not* intended here.
local_file_path = outdir + "/" + file_path
- files.append((file_path, local_file_path))
+ files.append((path + file_path, local_file_path))
if not files:
print("Nothing to do", file=sys.stderr)