Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have a .sh file with a #!/bin/bash header. I'm able to run it from the terminal, using chmod and ./ but is there a way to perform these two operations from the desktop (i.e. by clicking on it) ?

Btw, I'm familiar with linux, but not with OS X.

share|improve this question
    
Which operation do you want to perform from the desktop? The chmod or executing the script? Are you looking for a desktop shortcut to execute one specific script, or easy access to the shell from within the GUI? –  Gerry Feb 1 '13 at 14:40
    
I'm not entirely sure what you mean but if you just want to double click on it and have it run you need to change the extension to .command. This will open it up in a terminal. –  Tony Feb 1 '13 at 20:31
add comment

3 Answers

up vote 4 down vote accepted

You can add a .command extension to your text script.

Then use chmod 744 to make it executable.

When opened or double-clicked in the Finder it will then run from the Terminal.

share|improve this answer
add comment

Well you can wrap it inside a AppleScript, make a call to shell command (your bash script).

example: do shell script

do shell script "/bin/tcsh my-command-file-path"

save it as an application to your Desktop to run it.

share|improve this answer
add comment

You can put any commands into an AppleScript, and save the script as an applet, or a droplet, or use Automator to create applets and/or droplets. Just use the do shell script command in the AppleScript.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.