0

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:

#!/bin/sh
echo "**** committing remote changes on remote ****"
ssh [email protected]
cd /home/username/git/repo/
git commit -m "remote server commit"
exit

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.

1 Answer 1

1

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

3
  • That should all be one line btw...
    – opsguy
    Jul 20, 2011 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, 2011 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, 2011 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .