• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: osascript - path to me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: osascript - path to me


  • Subject: Re: osascript - path to me
  • From: Christopher Nebel <email@hidden>
  • Date: Fri, 17 May 2002 18:01:18 -0700

On Friday, May 17, 2002, at 05:48 PM, Joakim Jardenberg wrote:

On Saturday, May 18, 2002, at 01:58 AM, Christopher Nebel wrote:

Ah, the implicit PATH bug rears its ugly head again. The API 'path to me' uses genuinely doesn't know where the executable is in this case (though -600 is a rather weird error code) because all it knows is the name "osascript".

If you run osascript using the full path (i.e., /usr/bin/osascript), it should work.

Yep. It does. Problem is, it doesn't give the path to my scripts location. I know it sounds silly - in order to call the script thru osascript I must already know the path - but I want to make the scripts as portable as possible.

How would you make a script aware of it's own posistion in a fashion that works under all circumtances? And if thats not possible - how would you do it in the "osascript-case"?

A peculiarity of "path to me" is that it returns the path to the executing application, *not* the script being executed. The only way to get "path to me" to return the path to the script is to either make sure they're the same thing (i.e., make it an applet), or make the script runner handle "path to me" specially. (I think Smile does this; I'm not sure about Script Debugger.)

If you've saved an applet from the Script Editor in 10.1, it's actually a Mach-O executable, so you can launch it from the command line just by giving its full path -- no mucking about with "open" required.

The meta-question here is "why does your script need to know where it is?" The typical answer to this is "so it can locate some related resources it needs", which leads to the counter-question "why aren't you using AppleScript Studio to create an application bundle?"


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: osascript - path to me
      • From: Timothy Bates <email@hidden>
  • Prev by Date: Re: osascript - path to me
  • Next by Date: Re: Hello, I'm new here (now there's a classic)
  • Previous by thread: Re: Change mail.app username, account name and email address
  • Next by thread: Re: osascript - path to me
  • Index(es):
    • Date
    • Thread