From 98d5f7c43312e5cba33d7dca38b3fcffc10cd645 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 12 Aug 2013 16:20:11 +0200 Subject: 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. --- ftp-get.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ftp-get.py') 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) -- cgit v1.2.1