• 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
Finding and shelling out to a sh script in the same directory as the AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding and shelling out to a sh script in the same directory as the AppleScript


  • Subject: Finding and shelling out to a sh script in the same directory as the AppleScript
  • From: elliottcable <email@hidden>
  • Date: Wed, 4 Feb 2009 23:31:58 -0900

I have an AppleScript to be used in an AppleScript-using application (Adium), and I don't have any other options for usage. My goal is to create the simplest AppleScript possible that will do nothing more than 'farm out' to a Ruby script in the same directory as the AppleScript.

I've gotten thus far, but subsequently ran into a so-far insurmountable problem:

    on substitute()
  
      try
        set rubyScript to "linktunes.rb"
        set resourcesFolder to (container of (path to me))
    
        set scriptPath to quoted form of POSIX path of (resourcesFolder & rubyScript)
        if (do shell script "if [[ -f " & scriptPath & " ]]; then echo exists; fi") ≠ "" then
          return do shell script scriptPath
        else
          return "Error: " & scriptPath & " does not exist"
        end if
      on error errorString
        return "Error: " & errorString
      end try
  
    end substitute

Everything on the web indicates that `(container of (path to me))` should provide me with an alias to the folder containing the script - instead, I get this error:

"Error: Can’t get container of alias \"Geoffrey's RAID:private:var:folders:P2:P2S5eg-AGTiyqxkapijleU+++TI:-Tmp-:untitled_1odf.tmp\"."

(That's just an example, I get that error no matter where I save the file or even if I try running it as an unsaved file in the Script Editor).

How can I get a string containing the path of a file adjacent to the script being run (specifically, to be passed to `do shell script`)?
 _______________________________________________
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

  • Follow-Ups:
    • Re: Finding and shelling out to a sh script in the same directory as the AppleScript
      • From: Luther Fuller <email@hidden>
  • Prev by Date: Re: unable to execute javascript via applescript in acrobat - result "undefined"
  • Next by Date: Re: unable to execute javascript via applescript in acrobat - result "undefined"
  • Previous by thread: Re: unable to execute javascript via applescript in acrobat - result "undefined"
  • Next by thread: Re: Finding and shelling out to a sh script in the same directory as the AppleScript
  • Index(es):
    • Date
    • Thread