Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I find myself performing this REPL-like action quite often:

vim foo.sh
scp foo.sh host:/tmp/foo.sh
ssh host /tmp/foo.sh
# realizing it wasn't quite right
vim foo.sh
scp foo.sh host:/tmp/foo.sh
ssh host /tmp/foo.sh
# repeat many times

I was about to plow away at writing a shell script to make this simpler, but was wondering if someone smarter than me solved this problem more elegantly.

What's your solution? Besides emacs :)

EDIT: Why not just edit my file on the remote host? Simple, the hosts receiving my scripts won't always have a dev environment set up, so in this case host might not have all of my vim customizations; sometimes it'll be C code instead of a shell script, which means my workflow looks like:

vim foo.c
make
scp foo host:/tmp/foo
ssh host /tmp/foo
# repeat

That's why. I guess I want something with an interface like:

edit_loop foo.c --make --copy-and-run=host:/tmp/foo

What do you think?

share|improve this question

3 Answers 3

ssh remotehost bash < foo.sh
share|improve this answer

Step 1: Mount your remote host as a local folder using SSH-FUSE.

Step 2: vim ssh-mount/foo.sh

Step 3: From a second terminal, or forking from vim, run ssh host:.../foo.sh

Rinse and repeat.

Link: http://fuse.sourceforge.net/sshfs.html

share|improve this answer
1  
In fact, if you can run make with local tools, then you can use SSH-FUSE as in the C example, keep the source remote-mounted, and use local build tools. –  mpbloch Jun 21 '10 at 14:42

You don't need to repeatedly scp to the server; let Vim handle that for you automatically!

vim scp://user@host/path/to/file

You can then run ssh user@host in a separate terminal, and run make or /path/to/file there.

If you need a build environment that is not available on the server, you should instead check out the previous answer about sshfs.

share|improve this answer

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.