• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To get the last modified timestamp of a remote file over an ftp connection

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
At present, my application (running on, say Server 1) uses ftp connections (raw ftp commands) to connect to certain servers (say Server2 .... server n) within the network, access a particular path on server 2...n, list all the files in that directory, get the last modified time stamp of each file using MDTM and using some logic, filters out the required files based on this MDTM value.
Recently we came upon a server 2 whose ftp version does not support the MDTM command and they are pretty adamant about not supporting this command.
So now we will have to change our logic to get the file time stamps without using MDTM.

Any idea what my options are?



 
ruth abraham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops...forgot to mention, I cant use org.apache.commons.net.ftp.FTPClient.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Ruth. Have you checked the commons FTP API? FTPClient class
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My next step would be to ask the owner of the site what command their server supports which returns the last-modified timestamp of a file. If there isn't one, then no FTP client software is going to be able to get that timestamp.

And in that case the problem would be out of your hands and onto the desk of somebody else. It would then be a political problem and not a programming problem.
 
ruth abraham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks K! Great to be here! and thank you for your reply...

Paul, I guess you are right...But I am confused about one thing...If we were to connect to the same Server 2 using sftp, it works and we are able to get the time stamp. But for sftp connections we use the Maverick SFTP API and not our application code and are able to get a list of file object using a very simple "_sftpClientSession.ls(dirName)" !. So I tried checking the Maverick code to see what they would've used for this. However, I got overwhelmed, lost track and couldnt get to that point
I believe they would be using some ftp raw command ultimately......any leads in this direction???
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's interesting. Since I know really nothing about SFTP, I did a little bit of research. First of all Wikipedia says "sftp should not be confused with running an FTP client over an SSH connection" -- in other words, SFTP is not just a kind of FTP, it's a completely different thing.

The page I was looking at, this one: SSH File Transfer Protocol, gave me some links to the actual SFTP specs, but I didn't look at them. For one thing it's time for me to turn off the computer now, but mainly I already got the idea that SFTP isn't FTP.

But now that you've found out that SFTP works and can give you the information you want, can't you just use that instead of FTP?
 
ruth abraham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul....That does make sense....Apparently the server 2 team have no such command that returns the timestamp...So I guess I'll rework our logic...
I wish we could stick with sftp. Unfortunately though, they require both ftp and sftp support. Will come up with a workaround that would not need the timestamp.
Thank you for all your help....Appreciate it!
 
reply
    Bookmark Topic Watch Topic
  • New Topic