SBCL Run Shell Command

♀尐吖头ヾ 提交于 2019-12-10 20:43:32

问题


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.

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?


回答1:


Given the file test.py:

import sys
sys.exit(42)

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


来源:https://stackoverflow.com/questions/28956010/sbcl-run-shell-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!