Re: Get current working directory
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