Hi, if I am trying to run a shell-command in an emacs lisp function in which I call rsync (or scp) multiple times, which shell-command variant should I use? I am currently using shell-command, which locks up emacs until the process is done, and the output that should be visible with the --verbose to rysnc is not printed; I can use shell-command with an '&' at the end of the command string to make it asynchronous, which does print the progress - but while it doesn't 'lock up' emacs entirely, the minibuffer repeatedly asks if I want to kill the process which is crippling in the meantime; and start-process-shell-command, which appears to halt the function only after the first file/directory is transferred; neglecting the rest when there are multiple rsync calls made through my function. None of these seem ideal... any hints? Thank you much!
+2
A:
One solution might be to run the command in an actual shell buffer. Then you get to choose which one of those to run:
M-x shell
M-x eshell
M-x term
If you like that idea, you can code it up like this:
(defun my-rsynch-routine ()
"run some rsynch processes"
(with-temp-buffer
(shell (current-buffer))
(process-send-string nil "rsynch ...")
(process-send-string nil "rsynch ...")
(process-send-string nil "rsynch ...")))
Read more on 'process-send-string
for its usage. You might also want to have some error checking on the output from the processes.
Trey Jackson
2009-09-21 13:02:32
Hello Trey, thank you always. This time I had to choose with Jonathan's solution but as it was direct and well-suited for this purpose (and process-send-string seemed to work only in a buffer created and explicitly referenced (with get-buffer-create) rather than in temp-buffer...) but I am reading up on the filtering functions... there is much to grok and I am sure I will find uses at the end of it. Thank you again.
Stephen
2009-09-22 06:12:59
+4
A:
I have had the most success using start-process myself.
(start-process "process-name"
(get-buffer-create "*rsync-buffer*")
"/path/to/rsync"
arg1
...
argn)
This will send all the output to a single buffer.
Jonathan Arkell
2009-09-21 16:55:41