[Tutor] sftp in python without using pysftp or paramiko

Alan Gauld alan.gauld at yahoo.co.uk
Sat Oct 20 19:44:23 EDT 2018

On 20/10/18 21:07, Asad wrote:
> hi All ,
> I am looking to create a python script which logs in to the server and
> copies the fie from ftp to local system .:

The obvious answer is use pysftp.
But your subject says you don't want to do that.

So the next option is for you to write your own
version of pysftp, duplicating all the things
the author of that module did.

Of course for a non generic solution you only need
a fraction of the code, and you could use something
like pyexpect or an ssh module to reduce the effort.

> sftp abc at us.com 2100
> password : xxx
> sftp> cd /to_dir
> sftp > get file1
> sftp >exit
> Please advice .

I'd advise using the available modules.
But if that really is impossible use the next
level down. Reinventing the wheel is a painful
waste of time that usually only serves to
increase your respect for the inventor of
said wheel.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list