SBCL Run Shell Command
Asked Answered
R

1

3

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?

Roofdeck answered 10/3, 2015 at 4:9 Comment(1)
SBCL Manual: running external programs: sbcl.org/manual/#Running-external-programsLibretto
Q
4

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
Questa answered 10/3, 2015 at 5:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.