Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X - run shell script from the desktop GUI

You can create a shell script or a Python or Ruby script and run it on the Mac by using "Terminal" ... if you have Finder open, and you click on the icon for the file containing the source code of a saved shell script, is there a way to have that script run, instead of opening in my text editor ?

like image 879
dreftymac Avatar asked Jun 10 '10 16:06

dreftymac


People also ask

How do I run a script on my desktop?

To run from command prompt, use either Windows Key + R and type 'cmd' or click start and type 'cmd' into search box. Then you can drag your script to the command prompt window and press Enter to run it. If you wanted to run it by double click, you'd need something to stop it from finishing until you'd read the message.

Does Mac use shell script?

Mac's default shell is either zsh (Z shell) or bash (Bourne-again Shell). This default shell is determined by the version of macOS you're running. For macOS Mojave and earlier, the default shell is bash. For macOS Catalina and later, the default shell is zsh.


2 Answers

Yes - just put a .command suffix on the script.

Note: make sure the script is executable, e.g.

$ chmod +x myscript.command 
like image 58
Paul R Avatar answered Sep 21 '22 10:09

Paul R


Just another quick alternative is the tool platypus (http://sveinbjorn.org/platypus/). Free and good, but you can donate, if you want.

Platypus is a developer tool for the Mac OS X operating system. It creates native Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle along with a native executable binary that runs the script.

like image 25
alexrjs Avatar answered Sep 20 '22 10:09

alexrjs