我看过 Executing a shell command from Common Lisp及其答案,但我仍然不确定 SBCL 是否提供了一种从代码执行 shell 命令的方法。
SBCL Manual确实支持 POSIX,但我希望有更高级别的东西。具体来说,我想调用 Python 脚本并捕获返回值。有什么办法吗?
最佳答案
给定文件test.py
:
import sys
sys.exit(42)
您可以使用 sb-ext:run-program
运行它并检查退出代码如下:
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
关于python - SBCL 运行 Shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28956010/