Browse for shell script applescript

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

  1. flashuni macrumors newbie

    Joined:
    Jun 7, 2008
    #1
    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)
    [​IMG]

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

    Joined:
    Aug 30, 2006
    Location:
    US
    #2
    "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:

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

Share This Page