Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

I was looking for a module which would allow me to synchronize remote and local files via FTP.

I wanted to synchronize a local folder with a remote folder, and the only way of accessing the remote folder is via FTP.

Dreamweaver manages to do this, using a bit of a kludge to determine the time difference. It connects and creates a folder, checks the "created" timestamp on it, then deletes it again.

I could code that kind of solution quite quickly I suppose, but I'm surprised there's no module -- nothing I can find on CPAN anyway -- that even attempts to sync using FTP.



($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print

Replies are listed 'Best First'.
Re: Synchronize via FTP?
by graff (Chancellor) on Oct 30, 2006 at 06:18 UTC
    It seems as though the existing apps cited above don't cover your concern about actually confirming that both remote and local hosts have the same idea about what time it is. Given that Net::FTP supports a "mdtm" function (to return the modification time of a file), but not a "date" function (to return the remote host's system date), if you have doubts about one or the other clock being a bit off, touching a file on the remote host is probably the only way to check that.

    I'd be sure to get the local host's time-of-day both immediately before and immediately after creating the temp file on the remote host, so that I can take network latency into account. There could be other ways to query the remote host's clock, not using FTP at all (ssh for sure, don't know about others), but you'd always want to check for latency.

    If the remote host is in a different time zone (or follows different rules about daylight savings), that might raise issues.

Re: Synchronize via FTP?
by Anonymous Monk on Oct 30, 2006 at 05:08 UTC
Re: Synchronize via FTP?
by Anonymous Monk on Oct 30, 2006 at 05:14 UTC
Re: Synchronize via FTP?
by Anonymous Monk on Oct 30, 2006 at 05:16 UTC
Re: Synchronize via FTP?
by ww (Archbishop) on Oct 30, 2006 at 15:40 UTC
    CodyPendant -- would you clarify your selected meaning for "synchronize" please? Previous responses address a timestamp match, but to me, "synchronize" might more likely mean "contents match in a binary compare" (or, if Linux on one box and Win at the other end of the ftp connection, a rules-based compare, allowing for line_ending differences).

    UPDATE:
    answered below; appears that there is NO issue re content-matching.

      Simply that if a file is newer locally, it overwrites the remote file, and vice versa. Newly created files at each end should be added as well.


      ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
      =~y~b-v~a-z~s; print