ftp and lowercase?
Stein Surland
ssurland at online.no
Sun Jul 30 06:47:20 EDT 2000
J P wrote:
>
> Have you tried sendcmd ("ls") ? I think that would work for you.
>
> "Stein Surland" <ssurland at online.no> wrote in message
> news:39832544.2E05FCFB at online.no...
> > I have made a small script using ftplib to retrieve a list from a ftp
> > directory. It worked OK using ftp.retrlines('LIST', lines.append).
> > However using it on another ftp host gives me this message:
> >
> > ftp.retrlines('ls', lines.append)
> > File "/usr/lib/python1.5/ftplib.py", line 345, in retrlines
> > conn = self.transfercmd(cmd)
> > File "/usr/lib/python1.5/ftplib.py", line 285, in transfercmd
> > return self.ntransfercmd(cmd)[0]
> > File "/usr/lib/python1.5/ftplib.py", line 273, in ntransfercmd
> > resp = self.sendcmd(cmd)
> > File "/usr/lib/python1.5/ftplib.py", line 228, in sendcmd
> > return self.getresp()
> > File "/usr/lib/python1.5/ftplib.py", line 201, in getresp
> > raise error_perm, resp
> > ftplib.error_perm: 500 'LS': command not understood.
> >
> > The host did not take the LIST command so I changed it to LS and ls. It
> > seems that the ftplib sends the list command in uppercase. How to change
> > this to lowercase? I have ftp'ed to the host and it does not recognize
> > LIST or LS only ls.
> >
Sorry, my mistake! My line in the ftp script:
ftp.retrlines('LIST ', lines.append)
has a space after the LIST command. It worked well on one host, but not
on another. By closing it:
ftp.retrlines('LIST', lines.append)
it works OK. I was a bit flabbergasted by the 'command not understood'
error...
Stein
--
Stein Surland Trying is the first step towards failure
ssurland at online.no - Homer Simpson
http://home.online.no/~ssurland/
More information about the Python-list
mailing list