Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems simple enough... I'm trying to write a script that I can just double click on in OS X. The script is to login via SSH to a remote server, run a git commit and exit. When I copy/paste my commands into terminal they work but when I save them in a .command file it seems like it connects but then hangs, if I type exit into the terminal window that has opened, the script will continue where it left off.

The script/commands are just:

echo "**** committing remote changes on remote ****"
cd /home/username/git/repo/
git commit -m "remote server commit"

I'm new to writing scripts like this so it could be something really obvious I'm just missing (Since having read many q&a's here someone is bound to ask, yes my SSH keys are setup properly, copy/pasting this code works perfectly).

I don't think it relevant, but the server I'm getting to is a BlueHost/HostMonster shared web host with a jailed shell.

share|improve this question
up vote 1 down vote accepted

Haven't tried scripting from mac, but try this: ssh 'cd /home/username/git/repo/ && git commit -m "remote server commit"'

share|improve this answer
That should all be one line btw... – opsguy Jul 20 '11 at 5:49
Thanks! That seems to be getting me there... Ironically of course I seperated the lines a while ago to "aid in troubleshooting", didn't realize they were now the problem. Anyway it's now reporting that git is not found, but I know why that's happening, it's non-interactive shell and .bashrc isn't loaded so I need to hard code the paths... but I'm back on track to figuring this stuff out. – jb510 Jul 20 '11 at 6:10
Cool. Just comment here if you run into any more issues. And btw, I know this is self-serving, but it is in your interest to accept my answer. Sometimes people won't respond answer you if they don't think you'll ever come back and choose and answer. Either way, good luck! – opsguy Jul 20 '11 at 6:29

Your Answer


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.