Thanks L~R - at the risk of sending us both round in circles, I present the entire (short) program (as you suggest in readmore tags):
#!/usr/bin/perl use strict; use warnings; use Net::FTP; use POSIX qw(strftime); my $SERVER=xxx; my $USERNAME=yyy'; my $PASSWORD='zzz'; my $DIRECTORY='_test_data'; # a regexp my $filemask='\.stm$'; my $timeNow=time; # substract 14 days * 24 hours * 60 mins * 60 secs $timeNow-=(14*24*60*60); my $timeThen=strftime "%Y%m%d%H%M%S", localtime($timeNow); print "timeNow = $timeNow \n"; print "timeThen = $timeThen \n"; print "filemask = $filemask \n"; my $ftp = Net::FTP->new($SERVER, Passive => 1) || die "Cannot connect: + $!\n"; $ftp ->login($USERNAME,$PASSWORD) || die "Cannot login: ".$ftp->mes +sage." \n"; print "Connected \n"; $ftp->cwd("$DIRECTORY"); print "Changed directory\n"; my @files = $ftp->ls(); chomp( @files ); for my $file (@files) { print "Testing file : $file\n"; if ( $file !~ /\.stm$/) { print "Skipping : $file is not an .stm type file\n"; next; } my $mtime = $ftp->mdtm($file); die "cannot get mdtm for $file\n" if ! $mtime; print "$file last modified : ", scalar localtime($mtime), "\n"; if ( $mtime < $timeThen ) { print "Removing file : $file\n"; $ftp->delete($file); print $ftp->message, "\n"; } } print "quitting"; $ftp->quit();
This program runs fine with no error messages, but exits on the first .stm file with the "cannot get mdtm time" message.

The script is being run from a machine running Linux, although I don't at present know what flavour/version, likewise the remote server the script is 'operating' on.

Once again I am very grateful for your time and energy.

Thanks
stewartski


In reply to Re: Re: Re: Re: Re: Re: using $ftp->mdtm($file) by stewartski
in thread using $ftp->mdtm($file) by stewartski

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.