ask Safari to open a file in cd rom

I try to ask Safari to open a file in cd rom (after i finish another script in terminal)
a path into a cd-rom is really confuse me.
does any one have a example script for it.

and when i ask safari to open a specific file . the link inside html seems not working anymore. how can i solve it.

To open any file using Safari:

tell application "Finder" to open alias "CD:file.html" using application file id "sfri"

If “you” (your application) are running inside such CD, and you don’t know the CD name (?), you can use the “path to me” command to guess the name of the disk from where you are running:

set fullPathToMe to path to me as string
set CDPath to text 1 thru (offset of ":" in fullPathToMe) of fullPathToMe

So, if you know that your “file.html” is in the root of such CD:

tell application "Finder" to open alias (CDPath & "file.html") using application file id "sfri"

Of course, you can also use directly Safari, which may be more simple…

tell application "Safari" to open alias "CD:file.html"

Owen:

If you’re trying to open an HTML file from a Safari link, I think you can use this format:

file:///CD Name/Folder 1/Folder 2/File.html

Or, if you’re trying to open other files from links, you might try Missing Link:

http://www.mhtc.net/~bunnz/scriptlink.html

(A shameless plug for a script of my own…)

Peter B.


note that OS X mounts all external drives to the hidden folder /Volumes/ There are many other hidden folders also… try looking in /.hidden for folders that are there but hidden from the finder… as somebody coming to linux from a *nix background I edited this file so I can easily navigate /var and /etc but I don’t want to see anything OS 9 related… You can also add .hidden files to other folders for similar results!

You mean “execute a local scpt file from a link in your browser”?
There was some utilities in OS 9 and back. In OS X you must create your own protocol handler (as well as “mailto” opens your mail client or “carracho” your carracho client, you can create your own application to handle the “executescpt” protocol).
Missing Link is the intermediate way. As long as I know, it won’t execute compiled script, but will send a “open” event to any kind of file (and “opening” a scpt file will open it in your default script editor, not execute it).

Chopper:

In answer to your ‘every machine ?’ question, unless you’re talking about a local network (where Missing Link might work from a server, but hasn’t been tested for that use), then yes, each individual machine would have to have ML installed.

For instance, if you were to distribute a project with an HTML page and a selection of linked files, each end user would have to have the ML engine enabled for the links to work. In addition, ML works only locally… using absolute paths involving the disk name… it won’t work with relative link paths… so any working distribution would (probably) have to be on CD.

And jj is right, ML doesn’t work with either compiled scripts or script text files… only with stand alone script applications.

You could, as jj suggests, design your own protocol to execute compiled scripts or script text from disk locations relative to the protocol app, but the user would still have to make appropriate manual entries in a preference pane before use. As yet, I don’t think this can be done ‘automagically’ via script.

This is all ‘to the best of my knowledge’, so it should be taken with a grain of salt… or maybe several.

Peter B.

Missing Link