I do this kind of things very often (Every week) in Emacs when I restart it:
I was thinking: is there a way so that I can hard code these setups in the start-up scripts?
Here's a function that starts a shell, ssh-es to a host, and runs a command before dropping into an interactive shell:
(defun start-remote-shell (host command)
(shell (format "*shell-%s*" host))
(sleep-for 0 500) ; Wait half a second for the prompt to appear
(insert (format "ssh -t %s %s'; exec bash -i'"
(shell-quote-argument host)
(shell-quote-argument (shell-quote-argument command))))
(comint-send-input))
You can put this snippet into your .emacs
file, followed by the specific calls you want, such as:
(start-remote-shell "server-one" "apache start")
(start-remote-shell "server-two" "mysql start")
(start-remote-shell "server-three" "foo start")