Path to alias of script

Anyone know of a way to get the path to an alias of a script, as opposed to the path of the script itself? If i use a “path to me” in a script it still gets the path to the original script even if run via an alias of the script. I’ld like to be able to have a master script (so i can update it easily) and give out just the aliases to other users on our network, but i need to be able to get the paths to those aliases.

If that’s not possible, I seem to remember reading somewhere that you can get open one applescript with another, but am unsure of how to do that.

thanks!
Kyle

What are you doing that requires seperate files?

Hi Bruce -

The main thing I’m doing is using a script that creates a “project folder template” on our local server at the beginning of each new job we get at my office. Within that folder structure are the folders called “Web/_Utilities”, and in that i have the following script:

http://bbs.applescript.net/viewtopic.php?id=15126

I do this so that when i call up the password script above, i can easily get the location by using the path to me command. I need this so i can store a preferences file, etc.

This all works great, but if i ever want to update the password script, i have to remember to replace all the copies made in every project folder - so i thought an alias would work better, or some other way of calling the password script from another script, and maybe have the “path to me sent” as a variable.

phew - does that even make sense?
kyle

Kyle:

If all your folders contain an alias to a root script, whenever you update the root script, the aliases should be updated as well, is that not what you want? I do not think it would be necessary to find every alias of a script, if they are all exactly the same.

If you need different passwords for different folders, that is another story, however, and would probably require some kind of list file kept in some central location that all the alias scripts would examine for their own password, depending on their root folders. That could prove difficult to manage.

yup. totally - i can make the aliases call a root script, but for what i’m doing i will need to find the aliases paths, not the root scripts - cause i want to copy files to the aliases location.

I think i even read that applescript used to work like this but the behavior was changed over the years.

Kyle:

I have been playing around using UNIX links on this issue, and I seem to be making no progess. There are 2 different types of links, hard and symbolic. Symbolic links are similar to aliases, only slightly stupider. Unfortunately, the [path to me] yields the same as an alias; the path to the original script.

I had some glimmers of hope with the hard links, until I tried editing the original file. I was not allowed to save it, so I overwrote the original, but then the link was broken to the linked file in a different directory. I am a UNIX neophyte, and I have only limited textbooks and explanations, but I thought that hard links were supposed to allow one to alter the original file and maintain the link. I will try to look deeper into that, since the [path to me] works correctly with a hard linked script.

In case you are interested in pursuing the hard link issue, go to your Terminal and look up the man page for [ln].

Sorry I could help more.

As a workaround, is it possible to open a script that resides at a specified location with another script?
If so, i’ve read that’s its possible to pass a variable from one script to another, so instead of using an alias maybe i could create a very small script that just collects its own path and passes it along to the master script. That wouldn’t be too bad…

This might be able to do what you need. (It will require a small change to your script.)

If you’d like to try it, then save this script somewhere:

on run {theFolder}
	display dialog (theFolder as Unicode text) buttons {"OK"} default button 1
end run

Then save and execute a few different copies of this script (after you change the path, of course):

run script alias "Path to your script" with parameters {path to me}

Hey great, that’s what i was looking for! However, I’d love to read up more on passing variables around from script to script, but seem to be not having much luck finding documentation for this (my googling is giving me nothing specifically related) I’ve looked here as well, but I’m not finding anything. Sorry to keep asking so many questions, but do you know of any good resources for this?

thanks!
Kyle

Kyle:

This is the best book for just that topic:

http://macscripter.net/books/reviews/49_0_1_0_C/

Mr. Rosenthal spends a lot time explaining how to get scripts to call on each other, using script libraries, etc.

thanks!

Hi,

If you’re still looking for the path to an alias file, then there might be a way. If you’re running it by double clicking, then it will be selected and you can get the selection through the Finder.

gl,

Note that the run script command won’t preserve the persistence properties of the called script. I recently explained this in the later comments of a thread over @ AD:
http://discussions.apple.com/thread.jspa?threadID=232522&tstart=0