delete old files from FTP server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete old files from FTP server
# 1  
Old 09-19-2008
delete old files from FTP server

Hi

I just started learning Unix scripts.

I need to access an FTP server, delete all the files except the latest 6 files and the latest 6 files should be downloaded to my local server. Could some body help me to code this logic in KSH ?

Thanks
Athena
# 2  
Old 09-26-2008
Not really possible within KSH, afaik. If you explore Perl or Python, there are modules there to perform low-level FTP operations. Basically you would need to do something like this:

1. Login to site.
2. Get a directory listing.
3. For each file in the listing, perform a "stat" command, getting filesize and timestamp.
4. Sort file listing by time, separate into two groups (your last 6 and all others).
5. For all but the newest 6 files, delete them.
6. Download the 6.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete old files from FTP Storage

hello, we try to delete old files from ftp server. we are using that script. #!/bin/bash # get a list of files and dates from ftp and remove files older than ndays ftpsite="HOST" ftpuser="USER" ftppass="PASSWORD" putdir="PATH" # age of files they should delete ndays=1 # work out... (11 Replies)
Discussion started by: Seppelchen
11 Replies

2. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies

3. Shell Programming and Scripting

Delete files older than 1 year through FTP

Hi All, I want to login to a remote server using FTP command and then check for files older than 1 year and delete those files. Please let me know how can i achieve this using Unix Commands. Thanks in Advance, (10 Replies)
Discussion started by: HemaV
10 Replies

4. Shell Programming and Scripting

FTP multiple files from one server to one server

Hi, I'm new to shell script..I have one requriement like - In one server have more than one files,I want to ftp those files to some otehr server.. Ex : test1.pdf test2.pdf Please suggest me how to do (3 Replies)
Discussion started by: venkaswa
3 Replies

5. Shell Programming and Scripting

Need help creating a script to FTP files to a server and then delete the files that were transfered.

I am trying to FTP files to a Windows server through my Linux machine. I have setup the file transfer with no problems but am having problem deleting those files from the Linux box. My current non-working solution is below. Any ideas, anyone?? :wall: Please be gentle, I'm fairly new to this... (4 Replies)
Discussion started by: jmalfhs
4 Replies

6. Shell Programming and Scripting

script for to take files from FTP server to UNIX server and Unzipped that files

script for to take files from FTP server to UNIX server and Unzipped that files (1 Reply)
Discussion started by: sunilamarnadh
1 Replies

7. Filesystems, Disks and Memory

Not able to FTP the files to a FTP server

Hi , We are facing a weird problem in our project. we need to send some xml & audio files to a remote FTP server from a Linux box, we are doing this in Perl script using Net::FTP->. Issue here is.. when FTPed the files using Perl scripts, only empty files ( 0 byte) are getting created on the... (2 Replies)
Discussion started by: kishorepotta
2 Replies

8. Shell Programming and Scripting

how to restrict FTP users not to delete their files

Hello all, We have an FTP Server setup with VSFTPd and its working fine without anonymous login (we must maintain this standard) The requirement is to restrict users not to overwrite (and delete) their files. In other words, once their files are uploaded to FTP Server, they should not be... (1 Reply)
Discussion started by: prvnrk
1 Replies

9. UNIX for Dummies Questions & Answers

Reg: delete older files from ftp

Hi, I want to delete older files from ftp server. (files which are more than 5 days old). Please advice Thanks , sam (3 Replies)
Discussion started by: sam99
3 Replies

10. Shell Programming and Scripting

FTP multiple files from remote server to local server

Hi, I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is... (2 Replies)
Discussion started by: berlin_germany
2 Replies
Login or Register to Ask a Question