|
|||
|
Fetch Help > Concepts > Scripting
Fetch supports a number of Apple events. This makes it possible to automate tasks in Fetch with a scripting tool such as AppleScript. It also makes it possible for other programs to use Fetch as a helper application for resolving FTP and SFTP Uniform Resource Locators (URLs). This help topic describes Fetch's support for the URL, Fetch, and Interarchy Apple event suites. Fetch also provides a variety of Automator actions. You may find that setting up an Automator workflow to automate a Fetch task is even easier than using AppleScript. For more information, see the introduction to using Automator with Fetch and Automator actions help topics. Fetch supports Apple event recording. The easiest way to get a feel for scripting Fetch, or to find out how to script a task, is to turn on recording in your script editor, perform the task manually, and then examine the script that has been recorded. Most user actions will be recorded as script statements. For security reasons, Fetch will not record passwords, so when you run the recorded scripts you may have to furnish passwords, unless those passwords are stored in your keychain. It is also useful to examine Fetch's Apple event dictionary, since it provides a complete list of the supported object classes, properties, and events. You can download a set of example AppleScripts for Fetch from the Fetch Softworks website. If you used AppleScript with previous versions of Fetch, you should read the AppleScript changes help topic for more information about changes to Fetch's scripting terminology. URL Suite Fetch supports the geturl (GURL) event from the Standard URL Apple event suite, originally designed by John Norstad of Northwestern University and a group of Internet software authors. In AppleScript, the event is specified as follows:
The geturl event is used by the Mac OS and other applications to pass URLs to other applications for resolution. So email programs, web browsers, and newsreaders can pass FTP and SFTP URLs to Fetch using geturl. Fetch Suite Fetch supports the following object classes that are specific to Fetch:
Fetch objects also have properties specific to Fetch. For example, the application object has all the preferences settings as properties, so you can refer to its download folder or text line ending style. You can use the standard Core suite of events to manipulate Fetch objects. The standard events include close, count, delete, duplicate, exists, get, make, move, open, quit, save, and set. To this list Fetch adds the following events: download, view verbose file list, put into, send to, edit, edit image file, edit text file, get information about, mirror, refresh file list, view, view media, and view text. Here are examples of some of these events, used with a variety of Fetch Apple event objects: close text window "ftp.fetchsoftworks.com messages" Interarchy Suite Nolobe's Interarchy, originally known as Anarchie, was the first Macintosh FTP client to support scripting via Apple events. Fetch supports a subset of the Interarchy suite of events, to make it easier to reuse scripts written for Interarchy and Anarchie (and because it is a straight-forward and functional collection of events). The supported events are: To download a remote file: To upload a file: To delete a remote file or remote folder: To view a file list: To create a remote folder: To rename a remote file or remote folder: To edit a remote file with BBEdit (or other selected text editor): To send a raw FTP command: The user and password parameters for any of the Interarchy Suite commands can be omitted if you are using anonymous FTP. You cannot omit the path parameter when using the forms above. Also, the host, user, password, and path parameters can be replaced by a single url parameter; for example: fetch alias "My hard disk:my folder:cool file" url "ftp://fred:secret@ftp.example.com/remotedir/cool.file.hqx" If you want to use SFTP instead of FTP with any of the Interarchy suite commands, append "sftp true" to the command, for example: fetch alias "My hard disk:my folder:cool file" host "ftp.example.com" user "fred" password "secret" path "remotedir/cool.file.hqx" sftp true |
||