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

L~R - thanks for time & patience: I take your point about indentation. I will use <code> tags in future to preserve my code layout.

You are almost right in your assumption that $timeThen is an epoch time stamp (in fact time-(14*24*60*60) to give time in seconds 14 days ago). Also $connect is the same as $ftp in your code. I am using warnings and strictures.

Unfortunately, even using your modified code my program still dies on the first .stm file it finds with the 'cannot get mdtm' message.

However, if I comment out the 'die "cannot get mdtm ..."' line, I get this error message displayed (for every .stm file in the directory): "Use of uninitialized value in localtime at mdtm_test.pl at line 36."

(Line 36 is the 'print "$file last modified ... "' line). Then it prints the time last modified as "file name last modified : Thu Jan 1 00:00:00 1970"! The epoch if not much mistaken. Obviously my .stm files have been modified since then.

Not entirely sure what that error message is telling me but it's a start. I realise I will have to convert either the modified time into secs or the $stamp time into an epoch time stamp (possibly using POSIX strftime).

Thanks again for your time
Stewartski

  • Comment on Re: Re: Re: Re: using $ftp->mdtm($file)

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: using $ftp->mdtm($file)
by Limbic~Region (Chancellor) on Feb 25, 2004 at 16:14 UTC
    stewartski,
    You can't just comment out code all willy nilly. There is a problem, it told you what the problem is, you need to correct it before moving on. Now I can't guess as to what the problem is because you have not shown all the code, but it sounds like mdtm is on an operating system that does not work correctly or you are not passing it file names the process has permission to query. You will need to show more/all of your code - preferrably in readmore tags. You have me worried when you say $connect is the same as $ftp. Unless you have two concurrent FTP processes going at the exact same time in the same directory you can not interchange them like you did.

    Cheers - L~R

      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): 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

        stewartski,
        A quick cursory glance at your code doesn't reveal any immediate problem. So now I can only offer you possibilities.
        • See if it behaves the same way on a different server
        • See if it behaves the same way in active mode
        • Change $ftp->ls() to $ftp->dir() and manually parse the time stamp
        • Modify the mdtm sub from Net::FTP and possibly provide a bug fix.

        I will explain the last part now. You want to temporarily change the mdtm sub to the following:

        sub mdtm { my $ftp = shift; my $file = shift; return $ftp->_MDTM($file) || undef; }
        This won't fix anything - this is strictly to see what the stamp looks like. If you can subsequently modify the original code to properly parse it great - send in a patch. If not, post a new SoPW question saying how can I convert "X" into epoch time stamp.

        Cheers - L~R