Using ftplib to transfer files?

Using Ignition 7.* (have to make this change to a few different gateways of varying versions but all 7.8/7.9 and therefore jython 2.5)

Normally this was done with a batch file and winscp but I am just trying to see what is possible. I find getting outputs/errors from shelling out ugly/tedious and annoying especially if there is a way to do it with an existing library which is what I am trying to do.

I am using the same credentials I just verified work with WinSCP to get into the directory but I am getting a weird error when I try to do it via the ftplib in script console. There is only one machine that is both the gateway and client so I don't think is is necessarily a scope thing.

from ftplib import FTP

USERNAME = 'myUsername'
PASSWORD = 'secretPassword'
SERVER = '12.34.50.17'
PORT = 2022

ftp = FTP()
ftp.connect(SERVER, PORT)
tp.login(USERNAME, PASSWORD)
ftp.prot_p()
ftp.nlst()

This is just my attempt to connect to the server. I keep getting an odd error when I get to my ftp.connect(). I can't copy and paste unfortunately but here it is -

End of File error which seems odd. When logging in via WinSCP I just set it to SFTP and set the server, port (which is not the normal 22), user and password, nothing else and it works.

Does anyone here use ftplib to send files and how did you get it done? Or is this a wonky jython library I should avoid and should be shelling out for? Right now I just want to login and list the current directory to see that the connection is working.

Does that old version of ftplib even support SFTP? SFTP is really SSH--fundamentally not FTP at all.

Well that would explain the issue ha. I guess I will be going to shelling it out to winscp.

I don't know what I was thinking. it's called ftplib and I am trying to do sftp.