I just installed a program that currently must be launched from a shell script, which, in turn, must be run from Terminal. Is there an easy way to create an alias with an icon that, when double-clicked, runs the script to launch the program? This would be trivial in Windows with a shortcut to a batch file, but I am having the darndest time figuring out how to do it in OS X. Google searches turned up a number of suggestions, all of which appear to be obsolete or accompanied by several follow-up posts to the effect that "I tried this and it didn't work." I tried a few of them, myself (such as changing .sh to .command), and they didn't work for me, either.
If you give your script a .command extension and perform a chmod 777 on it (do make it executable), it will open and run in the Terminal when double-clicked.
If you give your script a .command extension and perform a chmod 777 on it (do make it executable), it will open and run in the Terminal when double-clicked.
As red_menace points out, there is the .command suffix.
You can also download Platypus (free download)
<http://www.macupdate.com/info.php/id/12046/platypus>
which can turn any script or Unix command line program into a double-clickable app.
You can use Applications -> Automator -> Run Shell Script, and save the workflow as an application.
I kind-of-like Platypus as it lets you control how you display any output from your script. The .command approach will launch Applications -> Utilities -> Terminal, and leave the window sitting on your screen. If you do not need the Terminal session, you have the chore of closing Terminal after running your script.
O.K., I can now run the script by double-clicking, but it fails. If run from Terminal, it succeeds. The purpose of the script is to launch a vendor (Oracle) program. Here's the script:
#!/bin/bash
cd "`dirname $0`"/bin && bash datamodeler.sh $*
It's run from the main vendor directory, in which sits a "bin" sub-directory, in which sits a shell script named "datamodeler.sh". I have (also) made it executable.
Here's the result of launching the outer script with a double-click:
==========
Last login: Tue Oct 5 23:19:02 on ttys001
/Applications/Oracle\ Data\ Modeler\ 2.0/datamodeler.sh.command ; exit;
Macintosh-6:~ mbwallace$ /Applications/Oracle\ Data\ Modeler\ 2.0/datamodeler.sh.command ; exit;
usage: dirname path
bash: datamodeler.sh: No such file or directory
logout
[Process completed]
==========
Again, if the outer script is run from Terminal, the end result is that the vendor program is launched.
I'm guessing that this is a relatively simple (but not to me) problem with the interaction between the Unix environment and the shell script.