Emacs shell命令与tramp模式等效
在 emacs 中,我可以交互地执行类似的操作:
Mx eshell
cd /sudo:privileged@myserver:
/path/to/mycommand
这很令人愉快,但我真的很希望能够在 elisp 代码中做这样的事情,作为自动化平凡任务的函数的一部分:
(shell-command "/sudo:privileged@myserver:/ path/to/mycommand")
这不太有效。显然 shell 命令试图找到路径 /sudo:privileged@myserver: 并且可以理解地抱怨。
是否有一种机制可以让我以编程方式在远程服务器上运行任意命令?我知道,在紧要关头,我可以求助于调用 `(shell-command "sshprivileged@myserver /path/to/mycommand")。不幸的是,由于我所处的网络怪癖,我在某种程度上依赖于流浪者多跳代理功能,因此从流浪者中执行此操作似乎更简单。
我查看了tramp.el以了解他们如何实现tramp-handle-shell-command拦截器,但看起来他们并没有考虑这种情况,或者也许我需要先欺骗它使用正确的缓冲区。我有什么选择?
(我使用的是 GNU Emacs,而不是 xemacs,以防万一)。
In emacs, I can do something like this interactively:
M-x 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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在
eshell
中运行命令,请使用eshell-command
。Use
eshell-command
if you want to run your command ineshell
.