- Blog
- Howtos
- anything generator
- apache
- asterisk
- autofs
- autoload
- automount
- backup db
- callcentric
- centos
- chumby
- cipher list
- cookies
- ctags
- dovecot
- glue fleece
- hacking
- httpd
- IE
- iFrame
- ispconfig
- javascript
- lighttpd
- media player
- move networks
- mysql
- mysqldiff
- mythtv
- Network Solutions
- openssl
- os x
- osx
- P3P Compact Policy
- php
- postfix
- proftpd
- proxy
- python
- screen scraping
- shell
- shell scripts
- slapd
- smb
- ssh
- sshfs
- SSLCertificateChainFile
- sslv2
- stunnel
- suphp
- taglist
- telnet
- trace
- verisign
- vi
- vsftpd
- Scripts
- About
OS X Run Shell Scripts From Finder
Submitted by adam on Thu, 2008-02-21 06:52.
If you want a shell script to be executable from Finder then you only need to follow two steps. No additional helper apps are needed; some exist but don't bother.
- Rename the shell script extension from .sh to .command
- Make the file executable - Either via the Terminal: chmod +x file.command or by Get Info in Finder
When the file.command is double-clicked/command-o in Finder, the Terminal will pop up and you'll see the script executed as well as the output.
Note 1: It does not work to symlink a current .sh script and make the symlink end in .command
Here's an example script I use to mount my code repository since I'm having trouble with AutoFS caching and failing to reconnect.
Example File: code_repos.command
#!/bin/sh sshfs adam@svn:/path/to/code_repos/ /Users/adam/ssh_mounts/code_repos -oreconnect,volname=code_repos
Example Terminal.app Output
Last login: Thu Feb 21 01:27:22 on ttys003 You have mail. /Users/adam/Desktop/Scripts/sshfs/code_repos.command ; exit; mosfet:~ adam$ /Users/adam/Desktop/Scripts/sshfs/code_repos.command ; exit; logout [Process completed]
Note 2:
Wherever you put the file, it will run with your home directory (ie: /Users/adam) as the current working directory.
To get around this, use the following line after the #!/bin/sh in your shell script. This will move the current working directory to the directory that contains your command file.
cd "`dirname "$0"`"

Exactly...
Exactly what I was looking for...Thanks! barrettmo