New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus • Advice and insight from world-class Apple enthusiasts • Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

How Do I Get Finder to Execute a Bash Script?


Post Reply New Thread Subscribe

 
Thread Tools
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,560
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM

mac57 is offline
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
QUOTE Thanks
rman

 
rman's Avatar
 
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,591
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac 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

rman is offline
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!
QUOTE Thanks
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,560
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM

mac57 is offline
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
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.
QUOTE Thanks
surfwax95

 
surfwax95's Avatar
 
Member Since: Aug 27, 2005
Location: Fayetteville, AR
Posts: 2,410
surfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud ofsurfwax95 has much to be proud of
Mac Specs: 15" Powerbook G4 • 24" iMac • iPhone 3Gs

surfwax95 is offline
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.
QUOTE Thanks
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,560
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM

mac57 is offline
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
QUOTE Thanks
puaerotch

 
puaerotch's Avatar
 
Member Since: Sep 21, 2005
Location: ohio
Posts: 809
puaerotch is a glorious beacon of lightpuaerotch is a glorious beacon of lightpuaerotch is a glorious beacon of lightpuaerotch is a glorious beacon of lightpuaerotch is a glorious beacon of lightpuaerotch is a glorious beacon of light
Mac Specs: iBook G4 OSX Tiger

puaerotch is offline
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
File Type: png Picture 1.png (26.3 KB, 4 views)
QUOTE Thanks
cradom

 
cradom's Avatar
 
Member Since: Feb 14, 2004
Location: Nederland, Texas
Posts: 3,102
cradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant future
Mac Specs: 21in iMac core2 Duo- 13in macbook - 10.9 on both

cradom is offline
Give the script the extension .term
When you double click it, it should open terminal and run.

Craig Domingue - resident redneck.
“Never argue with an idiot. He will only bring you down to his level and beat you with experience.”, George Carlin
QUOTE Thanks

Post Reply New Thread Subscribe


« Beginner...Please Help!! | Dashboard: Flipping widgets repeatedly?? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Show Item Info inflexion OS X - Operating System 15 10-24-2005 10:34 PM
Bash Script ftjogoh Apple Notebooks 1 11-04-2004 01:14 PM
Ooops - dragged a script to the Finder!! kjellquist OS X - Operating System 1 03-15-2004 06:46 PM
Simple finder hacking trip OS X - Operating System 0 03-07-2004 10:16 AM
"Invisify" files and directories in the Finder gatorparrots OS X - Development and Darwin 2 02-09-2003 11:24 PM

All times are GMT -4. The time now is 07:18 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?