Search code examples
emacsputtyorg-modeplinktramp

Strange results using tramp :session in org-mode


TLTR; If you use Emacs Org-Mode Tramp on Windows with Plink with SSH sesion. It creates strange outputs

Long Text: I use Emacs Org-Mode. Which is a great tool. And i liked to use in a literate DevOps way. Which is also a great Idea, document your work while you are on it.

You will hate me, i have to use a Windows station @work. So i tested it with Putty plink:

#+NAME: harddisk_worker001.sh
#+BEGIN_SRC sh :dir /plink:worker001:/tmp 
df --human-readable --local --exclude-type=tmpfs --exclude-type=overlay | awk '{print $5 "\t" $1}' | (read -r; printf "%s\n" "$REPLY"; sort --reverse)
#+END_SRC

#+RESULTS: harddisk_worker001.sh
| Use% | Filesystem                |
|  73% | /dev/mapper/system-lvroot |
|   6% | /dev/mapper/system-lvopt  |
|   6% | /dev/mapper/system-lvhome |
|  47% | /dev/sda1                 |
|   2% | /dev/mapper/system-lvtmp  |
|  27% | /dev/mapper/system-lvvar  |
|   0% | devtmpfs                  |

The Result was great, but i liked to also the :session feature of it, to speed it up:

#+NAME: harddisk_worker001.sh
#+BEGIN_SRC sh :dir /plink:worker001:/tmp :session worker001
df --human-readable --local --exclude-type=tmpfs --exclude-type=overlay | awk '{print $5 "\t" $1}' | (read -r; printf "%s\n" "$REPLY"; sort --reverse)
#+END_SRC

#+RESULTS: harddisk_worker001.sh
| Filesystem                |
| /dev/mapper/system-lvroot |
| /dev/mapper/system-lvopt  |
| /dev/mapper/system-lvhome |
| /dev/sda1                 |
| /dev/mapper/system-lvtmp  |
| /dev/mapper/system-lvvar  |
| devtmpfs                  |

Which was not the exspected result! Can you explain why the table differs? I am not able see the root cause of this. Except a bug in the tramp-plink implementation, but i am not sure about that.

Can you replay this?


Solution

  • I don't know too much about org, so I have debugged the resulting Tramp calls. Your first command results in org-babel--shell-command-on-region, which invokes a proper process-file call.

    Your second example, with the :session argument, doesn't seem to call any Tramp operation related to processes. So I believe org is trying something internally, which I cannot debug further. Maybe a process invocation which isn't Tramp aware, who knows.

    I recommend to write an org fault report.