---
title: LispKit System Call
group: Libraries
anchor: lp-lispkit-system-os
order: 71
---

Library `(lispkit system call)` currently defines a single procedure `system-call` for invoking external binaries as a sub-process of the LispKit interpreter. This library is macOS-specific and requires careful usage in portable code.

**(system-call _path args_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  
**(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).

{% highlight scheme %}
> (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
{% endhighlight %}
