On Wed, Oct 25 2023, alain.coch...@unistra.fr wrote: > Hello. > > For me, 'C-c C-c' on the following group > > #+begin_src bash :results output > echo "foo" > echo "bar" > #+end_src > > > works as I expect: 'foo' and 'bar' are echo'ed. But it fails on this > one: > > #+begin_src bash :results output > ssh coch...@fruc.u-strasbg.fr "echo foo>foo_file" > echo "bar" > #+end_src > > > The file 'foo_file' is created on the remote machine, but 'bar' is not > echo'ed. I have tried to insert other commands between the ssh and > echo commands, or append semicolons at the end of the commands, > without success. > > By contrast, it works with this one: > > #+begin_src bash :results output > ssh coch...@fruc.u-strasbg.fr "echo foo>foo_file" ; echo "bar" > #+end_src > > Perhaps it is worth noting that I observe the same behavior if I > simply copy/yank the commands (I mean: the two commands yank'ed at > once) in an emacs terminal (obtained with 'M-x shell'). However, > everything works as I expect if I copy/yank the commands (all at once) > in a "regular" X terminal (xfce in my case).
It looks like an issue in comint-mode and the way that it is handling the temporary ssh session. This is not an issue with org-mode. Here are a couple work-arounds: - add the -f to the ssh command - add a semi-colon and line continuation to the first line. Working examples: #+begin_src bash :results output ssh -f SSH-HOST 'echo foo>/tmp/foo_file' echo $(uname -a) |tee /tmp/uname.txt #+end_src #+RESULTS: : Linux t14 6.5.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.3-1 (2023-09-13) x86_64 GNU/Linux #+begin_src bash :results output ssh pearce-120 'echo foo>/tmp/foo_file' &&\ echo $(uname -a) | tee /tmp/uname.txt #+end_src #+RESULTS: : Linux t14 6.5.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.3-1 (2023-09-13) x86_64 GNU/Linux Not working: #+begin_src bash :results output ssh SSH-HOST 'echo foo>/tmp/foo_file' echo $(uname -a) |tee /tmp/uname1.txt #+end_src If you look at /tmp after running the third example, you see that that second command line has not been executed. Leo