z_a*_*xis 12 shell common-lisp exec ccl
在clisp中,以下代码有效:
(defun hit-history () (shell "tail ssqHitNum.txt"))
Run Code Online (Sandbox Code Playgroud)
但是,在Clozure CL中,shell不支持该功能!
dan*_*lei 10
不,没有标准方法,但有些库为重要的实现提供了这种功能.例如,Quicklisp中提供了一些简单的shell ,它提供了shell-command.(我实际上没有对它进行测试,但它是CLiki上推荐的库之一.)还有外部程序.更新:这些天似乎更喜欢劣质贝壳,正如Ehvince在评论和他自己的回答中指出的那样.
您还可以使用读取时条件来使不同的实现使用它们各自的功能来执行此操作.
CCL ccl:run-program例如:
CL-USER> (run-program "whoami" '() :output *standard-output*)
foobar
#<EXTERNAL-PROCESS (whoami)[NIL] (EXITED : 0) #xC695EA6>
Run Code Online (Sandbox Code Playgroud)
是的,对于ASDF的一部分UIOP,应将其包含在所有现代实现中。
uiop:run-program uiop:launch-program 所以举个例子
(uiop:run-program (list "firefox" "http:url") :output t)
Run Code Online (Sandbox Code Playgroud)
要么
(defparameter *shell* (uiop:launch-program "bash" :input :stream :output :stream))
Run Code Online (Sandbox Code Playgroud)
您可以在其中发送输入和读取输出。
它们在这里有更多解释:https : //lispcookbook.github.io/cl-cookbook/os.html#running-external-programs
trivial-shell不推荐使用,而由下层外壳代替,后者在内部使用可移植uiop的run-program(同步),因此我们可以使用它。