Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010

    Unanswered: 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";
    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 ) .
    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"; }


  2. #2
    Join Date
    Mar 2010
    or is there a way to delete all files older than 90 days or so?

  3. #3
    Join Date
    Mar 2010
    resolved the issue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts