从命令行与本地长时间运行的Common Lisp映像(可能已守护)进行交互 [英] Interact with a locally long-running Common Lisp image, possibly daemonized, from the command line

查看:127
本文介绍了从命令行与本地长时间运行的Common Lisp映像(可能已守护)进行交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令行与本地长时间运行的Common Lisp映像进行交互?

How could one interact with a locally long-running Common Lisp image, possibly daemonized, from the command line?

我知道可以运行通用终端命令提示符下的Lisp功能,我也知道

I know it is possible to run a Common Lisp function from a Terminal command prompt, I am also aware of this.

我需要做类似的事情,但是要使用本地的,已长期运行的 Common Lisp映像,以便能够从CLI或shell脚本中轮询可用的功能.

I would need to do a similar thing, but with a local, already long-running Common Lisp image, being able to poll available functions from the CLI or shell scripts.

是否有一种方法可以从CLI进行操作,例如从bash脚本调用一个函数,然后接收该函数返回的内容?

Is there a way to do that from a CLI, for example calling a function from a bash script, and receiving back whatever the function returns?

例如,尽管我可以使用 woo Hunchentoot ,调用函数并通过curlwget获取返回的值,但感觉有点复杂

I though one could, for example, create a primitive web service, perhaps using woo or Hunchentoot, calling functions and fetching returned values via curl or wget, but it feels a little convoluted.

当然,这是Emacs的SLIME的众多功能之一,但是我需要仅从CLI调用函数,而无需调用Emacs.

Of course, that is one of the many features of Emacs' SLIME, but I would need to call functions just from the CLI, without invoking Emacs.

在SLIME之外,也许有一种方法可以到达时髦的后端?

Is there perhaps a way to reach a swank backend, outside of SLIME?

如果可能的话,惯用的轻率的做法是什么?

If possible at all, what would be the lisp idiomatic way of doing that?

对于任何指针,我将不胜感激.

I would be grateful for any pointers.

很多年前,我能够通过telnet进入一个长期运行的LISP映像而对此很感兴趣(我相信在这种情况下,使用名字大写应该没问题).如果我没记错的话,可以在ipsec.franz.com上找到它.以某种方式连接的文章:远程登录以远程访问正在运行的应用程序

Many years ago, I was intrigued by being able to telnet into a long-running LISP image (I believe in this case uppercasing the name should be fine). If I remember correctly, it was available at prompt.franz.com. An article, somehow connected: telnet for remote access to a running application

Telnet当然是相当不安全的,但是至少由于某些原因,无论出于何种原因,以这种方式访问​​Lisp应用程序的用处都不能被夸大.

Telnet is of course quite unsafe, but the usefulness of being able to access the Lisp application(s) in that way, for whatever reason, cannot be overstated, at least to some people.

我要感谢Basile Starynkevitch的详尽详尽的回答,尤其是在理论方面.我一直在寻找一个更实用的方向,特别是与Common Lisp连接的方向.尽管如此,他的回答还是很有启发性的.

I would like to thank Basile Starynkevitch for his elaborate and thorough answer, especially on the theoretical aspect. I was looking for a more practical direction, specially connected to Common Lisp. Still, his answer is very instructive.

我已经准备好开始编写本地服务器了,也许使用了一个很好的Common Lisp库之一,例如:

I was all ready to start writing a local server, perhaps using one of the fine Common Lisp libraries, like:

  • usocket: Universal socket library for Common Lisp
  • iolib: Common Lisp I/O library
  • cl-aync: Asynchronous IO library for Common Lisp

但是,感谢斯坦尼斯拉夫·康德拉捷耶夫(Stanislav Kondratyev),我不必这样做.他指出了一个已经存在的解决方案,很好地回答了我的问题, ScriptL:Shell脚本使Lisp类似

But, thanks to Stanislav Kondratyev, I didn't have to. He pointed out an already existing solution that nicely answer my question, ScriptL: Shell scripting made Lisp-like

我已经在Linux,FreeBSD和OS X上成功进行了测试,只需确保在POSIX上安装薄包装器即可系统调用.在许多功能中(请参阅README),它允许公开选定的功能,正确处理安全性,甚至提供自定义的C客户端,该客户端在ASDF加载操作中进行构建,并支持许多新功能,例如I/O代替netcat.

I tested it with success on Linux, FreeBSD and OS X, just make sure to install the thin wrapper over POSIX syscalls first. Among many features (see README), it allows exposition of just selected functions, security is properly handled, and it even supply a custom C client, which builds as part of the ASDF load operation, and supports a number of new features, such as I/O, in place of netcat.

推荐答案

您可能会发现scriptl有用: http://quickdocs.org/scriptl/.但是,它依赖于iolib,后者依赖于一些非标准的C或C ++库,因此构建它并不是很简单.

You may find scriptl useful: http://quickdocs.org/scriptl/. However, it depends on iolib, which depends on some nonstandard C or C++ library, so building it is not quite straighforward.

如果您熟悉swank协议(似乎文档不足),那么确实有可能与swank服务器通信(请参见例如:https://github.com/astine/swank-client/blob/master/swank-description.markdown ).但是,这会通过网络公开TCP套接字,这可能是不安全的.我也尝试过,但是对IPC速度不满意.

It is indeed possible to communicate with a swank server if you familiarize yourself with the swank protocol, which seems to be underdocumented (see e. g. here: https://github.com/astine/swank-client/blob/master/swank-description.markdown). However, this exposes a TCP socket over a network, which could be unsafe. Once I tried that, too, but I was not satisfied with the IPC speed.

前一段时间,我编写了一个相当幼稚的SBCL特定服务器,该服务器使用本地域套接字进行通信,并使用C语言编写了一个客户端.这很原始,但是您可以看一下:https://github.com/quasus/lispserver .特别是,它支持交互式IO和退出代码.服务器和客户端构成了用于部署Unix风格软件的简单框架的核心.随时借用代码和/或与我联系以获取解释,建议等.

A while ago I wrote a rather naive SBCL-specific server that uses a local domain socket for communication, and a client in C. It's very raw, but you could take a look: https://github.com/quasus/lispserver. In particular, it supports interactive IO and exit codes. The server and the client form the core of a simple framework for deploying Unix style software. Feel free to borrow code and/or contact me for explanations, suggestions, etc.

这篇关于从命令行与本地长时间运行的Common Lisp映像(可能已守护)进行交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆