Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check for more recent file on remote server

Status
Not open for further replies.

charlotte49er

Programmer
Nov 17, 2001
25
US
I have been tasked with a project that potentially needs to download data from a remote server. The data is posted at irregular intervals and the name of the file changes slightly with each new post. Therefore, what I would like to be able to do is to connect to the server and check to see if there is a data file with a date later than what I currently have. I thought about using the fso but that seems to require knowing the filename. Does anyone have any suggestions on how to approach this? THANKS.
 
This list all files in a folder, using the FSO:
Code:
<%
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("c:\test\")   ' or use MapPath()
for each x in fo.files
  'Print the name of all files in the test folder
  Response.write(x.Name & "<br />")
  ' (or create a link)
next
set fo=nothing
set fs=nothing
%>

See: and


You may filter the output on various file attributes (see: but you write " a date later than what I currently have", and how will "The System" know that?





ttmug.gif
 
Thanks for the response. I know the time and date of the data that I currently have. I call an asp page via task scheduler to connect to the server and check for new data every x hours. I plan to use the last modified attribute to determine whether or not there is new data to be downloaded. From all of the examples that I have seen I haven't noticed where the fso was used with a url or ip address. Is this possible? If so, could I not it also connect to an anonymous ftp server and check the contents?
 
I already modified my code into this:

Code:
<%
dim cPeildatum
cPeildatum = CDate("2/6/2004 9:20:14 PM")

Response.Write "<table>"

dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder( server.mappath(".") )
for each x in fo.files
 
  if Cdate(x.DateLastModified) > cPeildatum then
   Response.write "<tr><td><a href=""" &_
                  x.Name & """>" & x.name &_
                  "</td><td>" &_
                  x.DateLastModified & "</td></tr>"
  end if
next
set fo=nothing
set fs=nothing

Response.Write "</table>"
%>



When i realized that this is not helping you.
"needs to download data from a remote server. "
"I haven't noticed where the fso was used with a url or ip"

I now presume this remote server is not yours. So you will not be able to put a script like mine on the server.
FSO is no solution.
Does the remote server has a page with all the available files? (Or maybe the server displays the folder content when you type the path in a browser). If you can present the folder content in a browser, you should be able to read this with an ASP program using XMLHTTP and find the correct filename...
More info on XMLHTTP:










ttmug.gif
 
Is it possible for you to request that the file be put into a specific folder where only it resides, nothing else?? Then you can check that folder for a file, download it and move/delete it from the folder. Then when the next file is ready it is put into that folder. That way you don't have to worry about file names, just look in that location.

Just a thought ....


Regards,

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top