LispPad
Search
K

(lispkit system os)

Library (lispkit system os) currently defines a single procedure system-call for invoking external binaries as a sub-process of the LispKit interpreter. This library is operating system specific and requires careful usage in portable code.
(system-call path args)
(system-call path args env) (system-call path args env port) (system-call path args env port input)
Executes the binary at path passing the string representation of the elements of list args as command-line arguments. env is an association list defining environment variables. Both keys and values are strings. The output generated by executing the binary is directed towards port, which is a textual output port. The default for port corresponds to current-output-port, a parameter object defined by library (lispkit port). Providing #f as port will send the output to /dev/null. input is an optional string which can be used to pipe data into the binary as input. The current implementation is not able to handle interactive binaries. system-call returns the result code for executing the binary (0 refers to a regular exit).
> (system-call "/bin/ls" '(-a -l))
total 863816
drwx------@ 47 objecthub 1504 Jun 8 10:56 Desktop
drwx------@ 96 objecthub 3072 Jun 7 16:39 Documents
drwx------@ 589 objecthub 18848 May 31 16:59 Downloads
drwx------@ 41 objecthub 1312 Dec 19 22:51 Google Drive
drwx------@ 84 objecthub 2688 Feb 15 18:32 Library
drwx------+ 16 objecthub 512 Oct 20 2019 Movies
drwx------+ 10 objecthub 320 Oct 20 2019 Music
drwx------+ 10 objecthub 320 May 17 18:37 Pictures
drwxr-xr-x+ 5 objecthub 160 Nov 23 2016 Public
0
> (system-call "/usr/bin/bc" '(-q) '() (current-output-port) "10*(11+9)/2\n")
100
0