hi
my purpose is just to connect to an FTP server and delete all files in
a directory
Is there a way using ftplib module? something like ftp.delete("*") ?
another way i can do is using LIST to list out all the files in that
directory, grab the filename, append to an array, then do a for loop to
delete one by one.
using the ftplib retrlines('LIST ') , it shows me all the lines with
-rw-r--r-- 1 user grp 6302 Apr 7 15:30 some file
how can i get only the filename?
thanks 1 1367
Well I am not too familiar with ftplib but I have done some minimal
work.
Example:
try:
server=FTP()
server.connect( 'ftp.mcafee.com ', 21)
except:
print "Could not connect to server"
raw_input("Hit Enter to quit:")
sys.exit(0)
login = server.login('a nonymous', 'f**@example.co m')
workdir = server.cwd("/pub/datfiles/english") ## Set the current
directory
server.delete(" *.*")
End Example:
I hope it helps This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: python |
last post by:
Hi:
I want to write a procedure to automatically upload some files for me, but
I'm getting stuck. Before I write my own gruesome put() function, I
wanted to check if there is an easier way.
Here's what I can do so far:
>>>import ftplib
>>>conn = ftplib.FTP('ftp.example.com')
>>>conn.login(user='userid', passwd='passwd')
|
by: Harlin Seritt |
last post by:
Using ftplib from Python I am trying to get all files in a particular
directory using ftplib and then send those same files to another ftp
server. I have tried using commands like 'get *' and 'mget *' with no
success.
I am using the following:
srcFtp = FTP(srcHost)
srcFtp.login(srcUser, srcPass)
srcDir = srcFtp.nlst('.')
|
by: vedran |
last post by:
Hello,
One simple question.Which security ftplib support,and how to I 'load'
these security to ftputil.
(Please don't give me security modules)
e.g.
ftp=FTPHost('myhost','myusername','mypassword',session_factory=ftplib.FTP)
|
by: Laszlo Nagy |
last post by:
Hi All,
I'm using a simple program that uploads a file on a remote ftp server.
This is an example (not the whole program):
def store(self,hostname,username,password,destdir,srcpath):
self.ftp = ftplib.FTP(hostname)
self.ftp.login(username,password)
self.ftp.set_pasv(False)
|
by: Jon Bowlas |
last post by:
Hi All,
I've written a little method to connect to an ftpserver which works well,
however when I send a file using this ftp connection oddly I _sometimes_ get
returned an EOFError from ftplib.getline even though my file is actually
transferred.
Here's my script:
def uploadViaFtp(self, file, filename):
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |