• 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: Get current working directory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get current working directory


  • Subject: Re: Get current working directory
  • From: "Mark J. Reed" <email@hidden>
  • Date: Mon, 3 Oct 2005 12:55:12 -0400

On 10/3/05, Thomas Vatter <email@hidden> wrote:
> This is the script that causes the problem
>
> do shell script "cd `dirname $0`; /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/java -jar ./prg/setup.jar"

Remember, $0 is a shell thing, not an AS thing.  It's set to the
location of the shell script file being executed, or, if there is no
file, to the pathname of the shell itself.   When you "do shell
script" from AppleScript, it just runs the shell with the supplied
string as an argument to the -c option, like so:

do shell script "echo 'Hello, world!'"

becomes

sh -c "echo 'Hello, world!'"

which means that $0 will only ever be 'sh' and `dirname $0` will return '.'.

If you're looking for the folder containing the AppleScript program
being run, you could try using "path to me", but that only works if
you compile the script as an app.  Otherwise it returns the path to
the host app instead (e.g. Script Editor).


--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Get current working directory
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: Get current working directory (From: Thomas Vatter <email@hidden>)

  • Prev by Date: Re: Get current working directory
  • Next by Date: Re: Getting at some Hidden Clipboard Contents
  • Previous by thread: Re: Get current working directory
  • Next by thread: Re: Get current working directory
  • Index(es):
    • Date
    • Thread