Post a comment |
Mana pirmā noderīgā Python programma | July 2nd, 2012 - 01:24 pm |
---|
#!/usr/bin/python
import ftplib
import re
import sys
def rlst(ftp, path):
subdirs = []
def dir_callback(line):
name = re.match("(?:[^ ]+ +){8}(.+)", line).group(1)
if re.match("[dl]", line): subdirs.append(name)
else: print(path + "/" + name)
ftp.dir(path, dir_callback)
for name in subdirs: rlst(ftp, path + "/" + name)
try:
ftp = ftplib.FTP(sys.argv[1])
ftp.login()
rlst(ftp, sys.argv[2])
ftp.quit()
except (ftplib.all_errors, KeyboardInterrupt) as e:
print(str(e))
|
|
Top of Page |
Powered by Sviesta Ciba |