SBCL运行Shell命令 [英] SBCL Run Shell Command
本文介绍了SBCL运行Shell命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到从Common Lisp执行shell命令及其答案,但是我仍然不确定是否SBCL提供了一种从代码执行Shell命令的方法.
I've seen Executing a shell command from Common Lisp and its answers, but I'm still not sure whether SBCL provides a way execute shell commands from code.
SBCL手册确实支持POSIX,但我希望更多更高层次.具体来说,我想调用Python脚本并捕获返回值.有什么办法吗?
The SBCL Manual does support POSIX, but I was hoping for something a bit more higher level. Specifically, I want to call a Python script and capture the return value. Is there any way to do this?
推荐答案
给出文件test.py
:
import sys
sys.exit(42)
您可以使用sb-ext:run-program
运行它,并检查退出代码,如下所示:
You can run it with sb-ext:run-program
and examine the exit code as follows:
CL-USER> (sb-ext:run-program "python" '("test.py") :search t :wait t)
#<SB-IMPL::PROCESS :EXITED 42>
CL-USER> (sb-ext:process-exit-code *)
42
这篇关于SBCL运行Shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文