简体   繁体   中英

Emacs shell-command equivalent with tramp-mode

In emacs, I can do something like this interactively:

Mx eshell <return>

cd /sudo:privileged@myserver:
/path/to/mycommand

That's pleasant and everything, but I'd really like to be able to do something like this in elisp code, as part of a function to automate a mundane task:

(shell-command "/sudo:privileged@myserver:/path/to/mycommand")

This doesn't quite work. Apparently shell-command tries to find the path /sudo:privileged@myserver: and understandably complains.

Is there a mechanism by which I can run an arbitrary command on a remote server programmatically? I know that, in a pinch, I could resort to calling `(shell-command "ssh privileged@myserver /path/to/mycommand"). Unfortunately, due to network quirks where I'm in, I'm somewhat dependent on the tramp multihop proxy feature, so it would seem simpler to do this from tramp.

I've looked at tramp.el to see how they implement their tramp-handle-shell-command intercepter, but it doesn't look like they consider this kind of case, or maybe I need to trick it into using the right buffer first. What are my options?

(I'm using GNU Emacs, rather than xemacs, in case it matters).

如果要在eshell运行命令,请使用eshell-command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM