Browse for shell script applescript

Discussion in 'Mac Programming' started by flashuni, Jul 9, 2008.

  1. flashuni macrumors newbie

    Jun 7, 2008
    Hello, I currently have a working script, but I want it to browse for the shell script to run. For example when you open a file it usually opens up the browser. I want to make the browser below pop up asking for a shell script to run (See the pict below).

    Here is a picture of what I am trying to do (But I am running leopard)

    Here is my code:
    tell application "Terminal"
    	do script "sh"
    end tell
    end open
  2. tedsmith3rd macrumors member

    Aug 30, 2006
    "choose file" is what you're looking for

    I think "choose file" is what you're looking for. It's part of the Standard Additions extension. In Script Editor, open the window menu and select library. You should see the scriptable apps you have (you can add terminal if it's not there) and some extensions like "Standard Additions." Look under that in the user interaction section for more info about "choose file" and related classes. You can customize the window a bit if you want.

    Anyway, here's an example that uses the code you provided:

    tell application "Terminal"
    	set myScript to (POSIX path of (choose file))
    	do script "sh " & myScript
    end tell

Share This Page