ftp seems to get a delayed reaction.

Jeremy.Chen you680 at gmail.com
Tue Jan 6 08:08:53 EST 2009


On Jan 6, 7:56 pm, Antoon Pardon <apar... at forel.vub.ac.be> wrote:
> I have managed to prune the script, so I can post it here:
>
> ==========================================================
>
> from ftplib import FTP
>
> bckrt = "/tmpstor/rcpc42"
>
> def process():
>   print "making directory"
>   try:
>     ftp.mkd('ftp-tst')
>     print "mkdir succeeded"
>   except Exception, ErrMsg:
>     print "mkdir failed: %s" % ErrMsg
>   fl = open("tstfile")
>   print "storing file"
>   ftp.storbinary("STOR ftp-tst/ftp-file\n",  fl)
>   fl.close()
>
> ftp = FTP('ftphost', 'user', 'passwd')
> ftp.set_pasv(False)
> ftp.cwd(bckrt)
>
> print "Doing once"
> process()
> print "Doing twice"
> process()
>
> ----------------------------------------------------------
> And this is the output:
> ==========================================================
> Doing once
> making directory
> mkdir succeeded
> storing file
> Doing twice
> making directory
> mkdir failed: 500 '': command not understood.
> storing file
> Traceback (most recent call last):
>   File "ftptst", line 24, in <module>
>     process()
>   File "ftptst", line 14, in process
>     ftp.storbinary("STOR ftp-tst/ftp-file\n",  fl)
>   File "/usr/lib/python2.5/ftplib.py", line 425, in storbinary
>     self.voidcmd('TYPE I')
>   File "/usr/lib/python2.5/ftplib.py", line 246, in voidcmd
>     return self.voidresp()
>   File "/usr/lib/python2.5/ftplib.py", line 221, in voidresp
>     resp = self.getresp()
>   File "/usr/lib/python2.5/ftplib.py", line 216, in getresp
>     raise error_perm, resp
> ftplib.error_perm: 521 "/tmpstor/rcpc42/ftp-tst" directory exists

ftp.storbinary("STOR ftp-tst/ftp-file\n",  fl)
----------
I think the params after STOR should't be a path,should be splited.
ftp.cwd("ftp-tst")
ftp.storbinary("STOR ftp-file\n",  fl)



More information about the Python-list mailing list