• 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: Why is the initial working directory of 'do script' root?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is the initial working directory of 'do script' root?


  • Subject: Re: Why is the initial working directory of 'do script' root?
  • From: Philip Aker <email@hidden>
  • Date: Tue, 12 May 2009 22:42:38 -0700

On 2009-05-12, at 19:28:34, Anthony Adachi wrote:

set p2m to quoted form of (POSIX path of (path to me))
do shell script "cd " & p2m & "; code-here"

You must of been reading my mind because that was going to be my next question: Reliable, recommended syntax to run shell script commands relative to the currently running script.

Regardless of whether or not I can read your mind, it would be best if I actually illustrated the correct code because the call above would have you try to cd into a file!

set p2m to quoted form of (POSIX path of (path to me))
set rslt to (do shell script "cd `dirname " & p2m & "`;code-here")

You may be interested in the advantages of the bundle format of scripts (extension .scptd) if you need to package an AppleScript and several shell scripts to attain a conglomerate facility.

In that case you can house your shell scripts inside the Resources/Scripts subfolder of a script bundle and use the 'path to resource "name.ext" in directory "Scripts"' call.





Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Why is the initial working directory of 'do script' root? (From: "Anthony Adachi" <email@hidden>)

  • Prev by Date: Re: Why is the initial working directory of 'do script' root?
  • Next by Date: RE: Script to conditionaly uncheck Hide and show Front Row
  • Previous by thread: Re: Why is the initial working directory of 'do script' root?
  • Next by thread: Get physical size
  • Index(es):
    • Date
    • Thread