Opened 8 years ago

#5978 new Enhancement

Suggested change to wiki regarding scripts

Reported by: Sesquipedalian Owned by: Waldorf
Priority: Normal Milestone: None Set
Component: Wiki Version: 2.84
Severity: Normal Keywords:
Cc:

Description

The Scripts page on the Transmission wiki currently has this to say about Applescripts:

Mac OS users may wonder wether there will be Applescript scripts, the answer is no. Although Applescript is a nice technology, it's a pain to implement. However, Mac OS X is a Unix after all, so any script you find here will also work on the Mac. Even from within Applescript, you can run these scripts by typing: do shell script "path/to/script".

It would be helpful to readers if this paragraph were changed to something like this:

Mac OS X users may wonder whether there will be Applescript support. The short answer is "No." Although Applescript is a nice technology, it's a pain to implement. However, Mac OS X is a Unix after all, so any script you find here will also work on the Mac. Even from within Applescript, you can run these scripts by typing: do shell script "path/to/script".

The long answer is "Not directly, but..." It is possible to create a shell script that uses Mac OS X's built-in osascript command to execute an Applescript. In the shell script, enter the following:

#!/bin/bash
osascript /path/to/your/applescript.scpt "$TR_TORRENT_DIR" "$TR_TORRENT_NAME" "$TR_TORRENT_HASH" "$TR_TORRENT_ID" "$TR_TIME_LOCALTIME" "$TR_APP_VERSION"

Then in your Applescript file, use the following format:

on run argv
     (* Receive the values that were passed in via the osascript command *)
     set {TR_TORRENT_DIR, TR_TORRENT_NAME, TR_TORRENT_HASH, TR_TORRENT_ID, TR_TIME_LOCALTIME, TR_APP_VERSION} to argv

     (* Your code goes here. You can use the variables named above in your Applescript code. *)

end run

Change History (0)

Note: See TracTickets for help on using tickets.