If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > delete remote files using wildcard and a variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-10, 11:51
sn15164 sn15164 is offline
Registered User
 
Join Date: Mar 2010
Posts: 3
delete remote files using wildcard and a variable

I want to delete all fiels with the filenaming convention HRPAY.sss.yymmdd where HRPAY is constant, sss and dd are numbers and yymm is dynamically figured out - 2 digit year and 2 digit month.

this is a piece of perl script I have written to delete remote files with wild card and a pattern. the pattern
"HRPAY*${gv_month}*" is not correct. how can I specify it?

#!/opt/perl/bin/perl -w


if ($ftp = Net::FTP->new($gv_ftp_host) ) {
print "Logging in to '$gv_ftp_host' as user '$user'.\n";
$ftp->login($user,$pw) or die "Could not login";
$ftp->pasv();
print "Changing directory to '$p_ftp_archive_location'\n";
$ftp->cwd($p_ftp_archive_location) or die "could not cwd $p_ftp_archive_location";
my @files = $ftp->ls("HRPAY*");
print "Found these files: \n\t" .
join( "\n\t", @files ) .
".\n";
foreach my $file (@files) {
if ( $file = "HRPAY*'${gv_month}'*" ) {
print "Deleting file: $file.\n";
$ftp->delete($file) or print "Could not delete $file\n";
}}
$ftp->close(); }

else { print "Could not connect.\n"; }


thanks.
Reply With Quote
  #2 (permalink)  
Old 03-31-10, 13:08
sn15164 sn15164 is offline
Registered User
 
Join Date: Mar 2010
Posts: 3
or is there a way to delete all files older than 90 days or so?
Reply With Quote
  #3 (permalink)  
Old 03-31-10, 16:47
sn15164 sn15164 is offline
Registered User
 
Join Date: Mar 2010
Posts: 3
resolved the issue
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On