Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get FTP's current working directory using python

How can I get current working directory of FTP using python?

I have the following code and wanted to store file names into the list in the root directory.

from ftplib import FTP

ftp = FTP('domainname.com')
ftp.login(user='username',passwd = 'password')
like image 880
Gowdhaman008 Avatar asked Oct 17 '25 15:10

Gowdhaman008


1 Answers

You can use ftp.pwd to get current working dir.

Ex:

from ftplib import FTP

ftp = FTP('domainname.com')
ftp.login(user='username',passwd = 'password')
ftp.pwd()                      #Current working dir
ftp.cwd("Destination_Path")    #To change to a different path

MoreInfo

like image 169
Rakesh Avatar answered Oct 20 '25 05:10

Rakesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!