Your best friend for file transfer.

Download newly modified items from FTP (4 posts)
- Started 20 years ago by kumpster
- Latest reply 20 years ago from kumpster
-
kumpster Member
-
kumpster Member
Oh - here is an example of what I mena. I began the mirroring process and left Fetch in the background to try to reduce errors. It got an error like the following:
400 Transfer failed: Conversion buffer overflow.
ftp_retrieve: -30000 (state == RGET_RETRIEVING)
PWDand the mirroring stops. Is there a way to continue the mirroring after such an error?
Thanks,
SteveOriginally posted by kumpster:
Hi List,
I am having trouble creating a type of mirroring system with AppleScript and Fetch. I need to poll an FTP server every few minutes and find directories that have been modified since my last visit and download thier contents, all JPG files and one text file. Seems strightforward enough.
I then have some applescripts perform some processing on the downloaded directories and thier contents.
My problem is as follows:
I list the contentents of the directory, then loop through the mod dats to determine what has changed since my last visit. If the dates are newer than the last date, I download the directory. Fetch seems to do this just fine most of the time. It doesn't list the contents of the directory it is downloading in the window, but just gets each item of that directory, and moves on to the next one.
However, if Fetch encounters and error, like an unexpected server response, which it seems to get quite a few from this particular .NET server (another topic for discussion) it switches the file list in the window to the contents of that directory it had problems with. And it gives an error message. Further, my script wants to go to the next item of the previous directory, so it is a pain.
What I have done is place the download command in a try and then, on error, set the remote item back to the original directory. But it still has all sorts of problems and sometimes opens news Fetch windows among other things. I simply want Fetch to ignore a problem file and move on to the next one...but this is proving more difficult than I anticipated.
I have tried using the mirro function, but it stops on the first sign of a problem. Is there anyway to stop Fetch from display dialogs at each error and simply toignore them? Or, can I refine my code to work around this?
Here is my code:
tell application "Fetch 4.0.3"
activate
set theWindow to make new transfer window at beginning with properties {hostname:theHost, userid:theUserID, password:thePAssword}
open remote item "theFolder"
set view order of theWindow to byDate
set itemCount to count theWindow each remote itemrepeat with itemIndex from 1 to itemCount
set currentItem to (a reference to remote item itemIndex of theWindow)
set modDate to modification date of currentItem
--if the modDate is newer than our test date, then continue
if modDate > Newestmoddate then
if item type of currentItem = isDirectory then
-- a folder, download it
try
with timeout of 30 seconds
download currentItem
end timeout
on error--an error occured, return to the previous directoryopen remote item "/theFolder/" of theWindow
end try
end if
end if
end repeat
end tellThanks!
Steve
-
Jim Matthews Administrator
Fetch should not display a dialog if the statement being processed is in a try / end try block. I would try (no pun intended) putting a mirror command in a block, and keep retrying the command until it succeeds. So you'd have something like:
with timeout of 3000 seconds
set done to false
repeat until done
try
mirror url "ftp://userid :password@host/path/" to alias "Hard disk:folder1:folder2:"
set done to true
end try
end repeat
end timeoutThanks,
Jim Matthews
Fetch Softworks[This message has been edited by JimMatthews (edited 06-03-2003).]
-
kumpster Member
Thanks Jim,
I have reworked my script until I got it to do exactly what I need, and now it works perfectly. However, it would still be less overhead to have Fetch do a mirror and then I can have my AppleScript look at the mirrored folder to find updates and work on them. So I will give it a try.
Thanks,
SteveOriginally posted by JimMatthews:
Fetch should not display a dialog if the statement being processed is in a try / end try block. I would try (no pun intended) putting a mirror command in a block, and keep retrying the command until it succeeds. So you'd have something like:
with timeout of 3000 seconds
set done to false
repeat until done
try
mirror url "ftp://userid :password@host/path/" to alias "Hard disk:folder1:folder2:"
set done to true
end try
end repeat
end timeoutThanks,
Jim Matthews
Fetch Softworks[This message has been edited by JimMatthews (edited 06-03-2003).]
- Page 1
Topic closed
This topic has been closed.
Hi List,
I am having trouble creating a type of mirroring system with AppleScript and Fetch. I need to poll an FTP server every few minutes and find directories that have been modified since my last visit and download thier contents, all JPG files and one text file. Seems strightforward enough.
I then have some applescripts perform some processing on the downloaded directories and thier contents.
My problem is as follows:
I list the contentents of the directory, then loop through the mod dats to determine what has changed since my last visit. If the dates are newer than the last date, I download the directory. Fetch seems to do this just fine most of the time. It doesn't list the contents of the directory it is downloading in the window, but just gets each item of that directory, and moves on to the next one.
However, if Fetch encounters and error, like an unexpected server response, which it seems to get quite a few from this particular .NET server (another topic for discussion) it switches the file list in the window to the contents of that directory it had problems with. And it gives an error message. Further, my script wants to go to the next item of the previous directory, so it is a pain.
What I have done is place the download command in a try and then, on error, set the remote item back to the original directory. But it still has all sorts of problems and sometimes opens news Fetch windows among other things. I simply want Fetch to ignore a problem file and move on to the next one...but this is proving more difficult than I anticipated.
I have tried using the mirro function, but it stops on the first sign of a problem. Is there anyway to stop Fetch from display dialogs at each error and simply toignore them? Or, can I refine my code to work around this?
Here is my code:
tell application "Fetch 4.0.3"
activate
set theWindow to make new transfer window at beginning with properties {hostname:theHost, userid:theUserID, password:thePAssword}
open remote item "theFolder"
set view order of theWindow to byDate
set itemCount to count theWindow each remote item
repeat with itemIndex from 1 to itemCount
set currentItem to (a reference to remote item itemIndex of theWindow)
set modDate to modification date of currentItem
--if the modDate is newer than our test date, then continue
if modDate > Newestmoddate then
if item type of currentItem = isDirectory then
-- a folder, download it
try
with timeout of 30 seconds
download currentItem
end timeout
on error--an error occured, return to the previous directory
open remote item "/theFolder/" of theWindow
end try
end if
end if
end repeat
end tell
Thanks!
Steve
Posted 20 years ago #