# Filename: ftp.py
from ftplib import FTP
import os
ftp = FTP("10.11.3.54")
ftp.login("","")
dirlist=[]
dirlist.append(".")
curdir=""
def sp(line):
l = line.split()
count = len(l)
if count == 9:
if l[count-1]!= '.' and l[count-1] != '..':
global curdir
global dirlist
c_d = os.path.join(curdir,l[count-1])
if l[0].startswith('d'):
dirlist.append(c_d)
print "[dir]%s"%(c_d)
else:
print "[file]%s"%(c_d)
def walk():
global dirlist
while len(dirlist) != 0:
d = dirlist.pop()
global curdir
curdir = d
global ftp
ftp.dir(d,sp)
walk()