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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP issue 1

Status
Not open for further replies.

nyzja

Programmer
Jan 13, 2005
31
0
0
US
I have a script that downloads some text files from a site. I have it scheduled to run automatically every hour. The problem is sometimes it succeeds, sometimes it fails, but there is no pattern of when it fails. The failure happens at the line MySite.connect. Following is the code (I tried with both FTP and SFTP).
Please help! Thanks!

Code:
   Set MySite= CreateObject("CuteFTPPro.TEConnection") 
   MySite.Option ("ThrowError") = True 

   MySite.Host = "sftp://login:pwd@some.site/"
   objShell.LogEvent EVENT_SUCCESS,"host set" 

   MySite.Connect
   objShell.LogEvent EVENT_SUCCESS, "connected to host" 

   If (Not Cbool(MySite.IsConnected)) Then	
      objShell.LogEvent EVENT_SUCCESS, "connect failed!" 
      MsgBox "Could not connect to: " & MySite.Host & "!"
      Set MySite = nothing
      Quit(1)
   End If

   MySite.LocalFolder = "F:\txtImports"

   myPath = "/data/export/" & myDate & myHour & "*"
   MySite.Download myPath
   objShell.LogEvent EVENT_SUCCESS, "downloaded" 

   MySite.Disconnect
   MySite.Close
   Set MySite = nothing
 
What happens if you run it 10 times in a row ?

Is it possible that the network connection to the ftp site is just flakey? or that the problem is with the remote server?
 
I tried to run it manually 20 times in a row (a minute after each other) and it didn't fail. The site is exclusively for us so nobody else is accessing it.
 
Can you get the ftp site logs from the operator of the remote machine?

You could compare this to your Event Log and maybe learn something. Perhaps a failed connection attempt on your side will have a more detailed explanation in the server log.

It is still valuable information even if you see nothing on the server side when you fail. Perhaps add some code to PING their server when you fail?

 
Try checking the status of the download, maybe it is attempting to disconnect during the transfer. Add a while loop to check the "MySite.IsPending" function. Maybe something like this (which I haven't tested):

while CBool(MySite.IsPending)
'wait a second or something here
wend


That's the only place I see that it may be bombing. The other place may be to check to see if you actually are making a connection.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top