简体   繁体   English

Emacs Shell命令等效于流浪模式

[英]Emacs shell-command equivalent with tramp-mode

In emacs, I can do something like this interactively: 在emacs中,我可以交互式地执行以下操作:

Mx eshell <return> MX eshell <返回>

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: 这很令人愉快,但是我真的很想能够在elisp代码中执行类似的操作,作为自动执行平凡任务的功能的一部分:

(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. 显然,shell命令尝试查找路径/ sudo:privileged @ myserver:并可以理解地抱怨。

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"). 我知道,在紧急情况下,我可以诉诸`(shell命令“ 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. 我查看了tramp.el,以了解他们如何实现其tramp-handle-shell-command拦截器,但是看起来他们并没有考虑这种情况,或者我可能需要先诱使它使用正确的缓冲区。 What are my options? 我有什么选择?

(I'm using GNU Emacs, rather than xemacs, in case it matters). (以防万一,我使用的是GNU Emacs,而不是xemacs)。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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