• 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? Was: Interacting with external shell scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts


  • Subject: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • From: Philip Aker <email@hidden>
  • Date: Mon, 11 May 2009 21:52:40 -0700

On 2009-05-11, at 16:52:54, Anthony Adachi wrote:

See: <http://developer.apple.com/technotes/tn2002/tn2065.html> for the straight-goods on 'do shell script'.

Interesting. I gather the default current working directory is not something that can be relied upon?

I think one could say it's consistent given the same context. However, that context (even for applications) is determined by the system and has no guarantee that it will be the same in other OS versions. 

What you can rely on in Mac OS X AppleScript is the 'path to …' command for getting well known system locations (including the current user's desktop, home, and other user sub-directories) and also, for running AppleScripts (i.e. those not being edited by a script editor), the 'path to me' command to give you the location of the script/applet/droplet currently being run. If you need to run a shell script in a location relative to the currently running script it's:

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

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: 
 >Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)
 >Re: Interacting with external shell scripts (From: "Mark J. Reed" <email@hidden>)
 >Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)
 >Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: Philip Aker <email@hidden>)
 >Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)

  • Prev by Date: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • Next by Date: Get selected text in Apple Mail?
  • Previous by thread: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • Next by thread: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • Index(es):
    • Date
    • Thread