using ftplib

Dave Hughes dave at waveform.plus.com
Tue May 2 14:05:20 EDT 2006


Steve Holden wrote:

> John Salerno wrote:
> [...]
> > 
> > So if I already have files on the server and I want to change file
> > permissions, do I need to mess with TYPE A/TYPE I commands, or are
> > those  strictly for when you transfer files? Because I just did a
> > quick test  of changing file permissions through my FTP program,
> > and it still sent a  TYPE A command in the process. I know that the
> > retr and stor methods  might do this automatically, but if I don't
> > need to use those, and just  need to use transfercmd (assuming this
> > is the right method to use when  changing file permissions), do I
> > need to manually send a TYPE A/I  command as well?
> 
> The answer is "probably not", but a better answer is "try it in the
> interactive interpreter and see".

As far as I recall your speculation is indeed correct: a TYPE command
is only necessary before a transfer (it's only used to transform data
passing over the secondary data connection). I'm reasonably certain you
don't need *anything* before a SITE command (like SITE CHMOD), not even
PORT or PASV (unless the specific SITE command being invoked requires a
data transfer, which CHMOD shouldn't). But as Steve suggests, the best
way to know for sure is to give it a whirl and see what happens :-)

Incidentally, you might like to experiment with the command line ftp
client. On both Linux and Windows, the "quote" command can be used to
send commands "raw" to the FTP server. For example:

ftp> quote SITE CHMOD 755 afile.py


Dave.

-- 




More information about the Python-list mailing list