The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting a file from REMOTE Unix Server Raamc Shell Programming and Scripting 2 10-22-2008 10:42 AM
Deleting a file located on another server SanketJOSHI Shell Programming and Scripting 2 05-08-2008 08:02 AM
Deleting a file located on another server SanketJOSHI UNIX for Dummies Questions & Answers 1 05-08-2008 07:29 AM
df -k and deleting files ajayr111 UNIX for Dummies Questions & Answers 4 03-14-2007 08:03 PM
Deleting old files shiroh_1982 Shell Programming and Scripting 2 06-21-2006 05:42 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-13-2009
arunsoman80 arunsoman80 is offline
Registered User
  
 

Join Date: Jul 2008
Location: New York
Posts: 45
Question Need help in deleting old files from a ftp server

Hi,

I'm quite new to unix and perl scripting and need to write a script to delete files older than 7 days from a remote ftp server. Unix or Perl script would do...

I wrote the following code:

#!/usr/local/bin/perl
use File::Basename;
use Net::FTP;
#use Net::FTP::File;
my $verbose = 0;
my $proxy = @ARGV[0];
my $host = @ARGV[1];
my $ftpuser = @ARGV[2];
my $ftppass = @ARGV[3];
my $remoteDir = @ARGV[4];
my $filetoDelete = @ARGV[5];
my $ftp=Net::FTP->new($host,
Debug => 0,
Passive => 0,
Hash => ($verbose ? \*STDOUT : undef),
FirewallType => 1,
Firewall => $proxy,
) or exit(1);
$ftp->login($ftpuser,$ftppass) or exit(2);
chomp($remoteDir);
if ( $remoteDir ne "/" )
{
$ftp->cwd($remoteDir) or exit(3);
print $remoteDir;
}
@files=$ftp->ls or exit(4);
foreach(@files) {
print "$_ \n";
$ftp->delete($_) ;
}
$ftp->quit;
exit(0);

I'm not able to find a way to identify files of pattern aaa* that are older than 7 days. Unix and Perl gurus, please help...

regards,
Arun
 

Bookmarks

Tags
mtime, perl net::ftp

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0