Re: FTP basics (and more)
Re: FTP basics (and more)
- Subject: Re: FTP basics (and more)
- From: Richard 23 <email@hidden>
- Date: Fri, 10 Nov 2000 23:59:07 -0800
>
In response to my previous question, about finding files with certain
>
modification dates, I was pointed towards the FindFile OSAX which does
>
the trick indeed.
You're lucky. I tried that on a whim and crashed. I decided that I
wasn't in that much of a hurry after all and removed it.
>
Great, that was easy. Now for the stuff that will involve more coding:
>
the ftp part. It's been a long time since I looked at the innards of ftp
>
and my memory on it is pretty fuzzy, so please forgive my ignorance.
>
These are the steps as I remember them:
>
1. Log in with username and password, this opens a connection
>
that will stay open for the remaining steps.
>
2. Go to directory where you want to do stuff.
>
3. Do stuff: remove or create directories, remove or upload files.
>
- In order to update an existing file, you need to explicitly
>
delete the old one first before sending the new one.
>
- To upload a directory with contents, you need to create the dir
>
first and then upload the files one by one.
>
4. Repeat steps 2 and 3 as long as necessary.
>
>
Am I correct so far?
That's about right although you do the username password and directory
all in a single request. Then you deal with the window. Minor detail.
Too bad the script isn't that terse!
>
What solution would you suggest for this, AppleScript an application or
>
use an OSAX? And for both cases, which app or OSAX could you recommend?
I've written one script for this and apart from making little changes
now and then, ended my ftp scripting career. So I can't make comparisons
for you. Fetch is a pretty stable program, has been around for a long
time
and hasn't been updated in awhile (suggesting stability or a dead end!),
So unless someone wants to rave about Anarchie (or is it Interarchy now?)
I'd go with Fetch. Scripting it was pretty straightforward as I recall.
The script I wrote was a little over the top, but a little overview might
give you some ideas for your own script.
It would look in the frontmost application, expecting to find BBEdit or
Alpha (I call the script using OSA Menu). it would then search* the
document window for "#directory: " and extract the upload directory
hidden somewhere in the text of my document. Then if the document was
modified, it would be saved since the file, not the window was being
Finally the location of the file in the application's front window
was requested and stored in a variable.
* Each text application has its own way of searching documents and
scripting windows so I wrote a routine for each one I commonly use.
If not already open, it would tell Fetch to open a new transfer window,
supplying it the url, username and password. The password would only
be needed if a window for the url was not already open.
If the target url was in the bookmark list, the script asked Fetch to see
if there was a username and password there before finally pestering the
user (queried if not saved in the script, optional for security reasons).
Although I didn't look into this you may also be able to obtain the
login information from the keychain. Anarchie is keychain aware, but
haven't scripted it, and don't know if you get keychain info directly or
through the application you're scripting but you might want to look into
that.
Finally the actual upload takes place, then depending on what browser
was open (another set of routines for each browser) the front window
was checked. If the url of the upload and the the url in the front
window matched, the browser window would be refreshed and brought to
the front.
Now that's how you script uploads! 8)
Someday I'll put it on my site...but not today.
Hope that gave you some ideas and wasn't just a waste of everyone's time.
R23