Wednesday, May 02, 2007

Getting a real shell

At my work I have been making a bunch of textmate commands to automate some of the build process, and specifically launching the currently open file. To do this, I run a command kind of like this:

ssh root@.... "copytobeta $TM_FILENAME"

(note: this is a bit simplified, and I have my computer setup with shared keys, so I don't have to login :-)

cpBeta is a command we have on our servers. However, when I try this I get that the command cpBeta can not be found. Clearly the problem here is that the environment variables are not getting passed correctly, so next I tried running everything in the sh command

ssh root@.... "sh -c \"copytobeta $TM_FILENAME\""

still no luck. I tried all kinds of things, first running /root/.bash_profile, then /root/.bashrc... nothin..

So finally one of my co-workers pointed me to the --login option of sh (or bash) The solution looks something like this.

ssh root@.... "sh --login -c \"copytobeta $TM_FILENAME\""

No comments: