Results 1 to 8 of 8
  1. #1

    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    How Do I Get Finder to Execute a Bash Script?
    I have created a shell script that I would ideally like to have Finder cause to execute when I double click on it. I created the script, changed its permissions so that it was executable, and then tested it from within Terminal.app. It works fine there. However, when I simply double click on the file from within a Finder window, it treats it like a text file and opens it in TextEdit.app. How can I make it execute the file instead? Thanks!
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  2. #2

    rman's Avatar
    Member Since
    Dec 24, 2002
    Location
    Los Angeles, California
    Posts
    12,584
    Specs:
    2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi
    Cool
    Here is my guess. You may need to add an extention to the file you created. Something along the lines of .app. I hope it is that simple.
    Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!

  3. #3

    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Hey rman, I managed to solve this one myself! I had tried the .app idea as well, thinking "well, everything else is simple on the Mac, perhaps this is the way" but it didn't work.

    Here is what I did. The script in question launches an X11 based program with a unique parameter set. So I did a Get Info on the script's file and changed its "Opens With" entry to "X11.app". It worked perfectly!

    This isn't a general solution to getting Finder to execute a bash script, but it worked in this instance, and for now, I am happy with that. I would like a more general solution long term, but for now, I have accomplished what I need to.

    Thanks for the help though!
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  4. #4

    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    Perhaps you created the script using TextEdit? If so, the creator flag is set to TextEdit and it will open it. This would suggest that you could change it by opening the Info panel and associating the script with say, the Terminal app.

    Via the Finder, use the Go option to open the /bin directory. Take a look at the Info panel for the ls command. Copy the idea.

  5. #5

    surfwax95's Avatar
    Member Since
    Aug 27, 2005
    Location
    Fayetteville, AR
    Posts
    2,406
    Specs:
    15" Powerbook G4 • 24" iMac • iPhone 3Gs
    xStep may be right, you may want to use pico or nano in Terminal and just write out from there.
    I try to Command+Shift+/ when I can.
    They're - Their - There | Two - Too - To | You're - Your | MAC - Mac
    I was on the M-F honor roll for October, 2006.

  6. #6

    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    xstep, that sounded promising, but when I attempted it, with the Get Info panel, to set the "Opens With" to Terminal.app, it wouldn't let me. Terminal.app was grayed out and not selectable. Darn!
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  7. #7

    puaerotch's Avatar
    Member Since
    Sep 21, 2005
    Location
    ohio
    Posts
    809
    Specs:
    iBook G4 OSX Tiger
    Quote Originally Posted by mac57
    xstep, that sounded promising, but when I attempted it, with the Get Info panel, to set the "Opens With" to Terminal.app, it wouldn't let me. Terminal.app was grayed out and not selectable. Darn!
    try changing it from Recommended Apps to All apps at the top of the Opens With dialog and see if it works
    Attached Images Attached Images

  8. #8

    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Groves, Texas
    Posts
    4,561
    Specs:
    21in. iMac 10.11 --- HP Linux Mint 18
    Give the script the extension .term
    When you double click it, it should open terminal and run.
    Delusions are often functional. A mother’s opinions about her children’s beauty, intelligence, goodness, et cetera ad nauseam, keep her from drowning them at birth.
    -Lazarus Long

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. rSync commandline bash script
    By scar1 in forum OS X - Operating System
    Replies: 2
    Last Post: 03-19-2015, 09:49 PM
  2. Replies: 1
    Last Post: 07-16-2013, 08:45 AM
  3. Newbie help with bash script to search and replace a filename
    By gilc in forum OS X - Development and Darwin
    Replies: 5
    Last Post: 02-25-2010, 04:23 PM
  4. Help with the bash...alias/script...?
    By Antares in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 10-26-2009, 12:32 PM
  5. Bash Script
    By ftjogoh in forum Apple Notebooks
    Replies: 1
    Last Post: 11-04-2004, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •