views:

172

answers:

3

I have a bash file that does some file manipulation. I don't want to have to open the terminal every time I run it. Is there a way to make the program run when I double click it? (Like a windows .exe file)

Thanks

+3  A: 

What you need is Platypus.

Platypus is a developer tool for the Mac OS X operating system. It can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl and Python programs. This is done by wrapping the script in an application bundle directory structure along with an executable binary that runs the script.

Zifei Tong
maybe this is only for linuz, but isn't there a way to change the file to make it an executable?
jamesatha
@jamesatha: Mark the file executable via `chmod +x file` and then make sure the first line reads `#!/bin/bash`.
Borealid
That just makes a file executable in a shell. It does not make it something that can be clicked to launch in the OS X finder. Simplified, for that it either needs to be an OS X .app or its file type needs to be handled by an .app.
Ned Deily
(To be clear, *that* in my comment above refers to the `chmod` suggestion.)
Ned Deily
+1  A: 

With OS X 10.5+, you can wrap the bash shell script in an AppleScript application using the AppleScript editor or an Automator application using Automator.app (see the Automator on-line help).

You could write (and there are apps out there that do this) an OS X app that accepts arbitrary .sh files and executes them. However, that's generally a bad idea as it could open you up to attacks if you inadvertently download a malicious shell script file that is automatically opened by your web browser. Better to be explicit.

Ned Deily
+1  A: 

You can add a ".command" extension to the filename -- then double-clicking it will automatically open Terminal and run the script in a new window. Note: this assumes you still want to watch/interact with the script via a Terminal interface; if you want to avoid this as well, wrapping the script with Platypus, AppleScript, or Automator (as Zifei and Ned suggest) would be better options.

Gordon Davisson
I didn't know you could do that. At the time, I just set the default application to the Terminal
jamesatha