I’d like to start this node with a question:
Kai Großjohann had inquired about the same issue on tramp-devel/2002-09:
I was wondering if there is a simple way [ie a simple change or setting in either eshell or tramp] which inserts the output a remote command into the current eshell buffer…
I have it working successfully with TRAMP on a Win32 machine, via PuTTY. Nothing special about my setup, here’s the TRAMPy part:
(require 'tramp) (setq tramp-debug-buffer t) (setq tramp-default-method "plink") (setq tramp-auto-save-directory (concat "d:\\tmp\\" user-login-name) ; (Windows)
tramp-default-method seems to be the important thing, to save it guessing how to connect. I can then cd like so:
So long as the hostname (“PUTTYCONFIG”) has been saved by Putty, it’s fine.
I have not tried with other TRAMP methods like ssh (we’re using Windows to reach into Unix hosts here, I know crazy…) but if the default is set to something that works, I think eshell should be fine.
This allows you to further process the string within a lisp expression. The key here is to pass standard-output as the 2nd arg to shell-command. That’s the only buffer that with-output-to-string will look at. By default the output from shell-command goes elsewhere, and with-output-to-string will come up empty handed.
(with-output-to-string (shell-command "COMMAND" standard-output))
/ssh:myhostname.domain.com:/home/myuser $ (split-string (with-output-to-string (shell-command "hostname" standard-output)) "\\." ) ("myhostname" "domain" "com\n")