Re: Applescript and FTP
Re: Applescript and FTP
- Subject: Re: Applescript and FTP
- From: Richard 23 <email@hidden>
- Date: Thu, 4 Jan 2001 13:45:45 -0800
>
I personally find Interarchy's AppleScript support to be just about the best
>
when it comes to scripting FTP transfers. If you don't mind relying on an
>
application to get the job done, I would suggest you take a look at it. You
>
can find it on http://www.versiontracker.com.
It is a little annoying that you can't specify which window you want to
close.
Close operates on the first window only. In fact window queries only
operate
on the front window. If you want to close window 2 without disturbing
window
1 you're out of luck baby!
If you get disconnected while files are still queued the windows just keep
on opening and dying. I ended up with about 80 windows open when I got
disconnected during a batch transfer!
If you want to continue those downloads its simple enough to have the
Finder
locate them but you can't queue them up again. Tell InterArchy to open
them
and it sure does. All of them at the same time!
My speaking ftp script for InterArchy functions as a stay open script and
tells InterArchy to download one by one via an idle handler. My script
has to guess whether a window has died or is actually still working
because
there's no way to query it whether it's made any progress since the last
idle timeout. That really bites.
Often windows will just stall displaying a "0k" transfer rate with the
time remaining increasing rather than decreasing every second. Neat!
--
---------------------------------------------------------------------------
--
-- keep closing the frontmost window (the only one visible to the script)
-- until one is encountered that didn't stall or end up with an error
--
---------------------------------------------------------------------------
--
on CloseErrorWindows()
if HasErrorWindow() and (say kCleanUp) then try
repeat while HasErrorWindow()
tell application "Interarchy" to close
end repeat
end try
end CloseErrorWindows
In order to know whether a window is open or not, you have to test for
a window. If you get an error, there's no window! Error windows have
parenteses around the name... So that's how you detect those:
-- ----------------------------------------
-- get name of frontmost Interarchy window
-- or false if none (or an error window)
-- ----------------------------------------
on GetFrontWindow()
tell application "Interarchy" to try
name of (frontwindowrecord)
if not (result starts with "(" and result ends with ")") then
result
else
false
end if
on error
false
end try
end GetFrontWindow
Here's what you get for working with windows:
frontwindowrecord: returns the record for the front window
Class window: a window: bounds, name, position
That's it!
I wouldn't give it high marks for scriptability.
The wands (specialized windows) look neat and the ability to get a listing
of all the files referenced in an html page is pretty cool (but pretty
easy
to do yourself in AppleScript).
Hope the next version maybe adds some more AppleScript goodies.
To be honest I'm not really sure whether I'd recommend it over Fetch.
At least with Fetch you can access windows by index and access useful
properties, little things like status, approximate item size,
bytes transfered, elapsed transfer time...
Scripting InterArchy (version 3.8 anyway) was a lot like working in the
dark...
Well it's been 10 minutes now.... it doesn't look like NetScape 6 is
going to complete that launch. I heard the startup was slow but I
suspect something may have gone wrong....
R23