NextPrevUpTopContentsIndex

call-system

Function
Package

system

Signature

call-system command &key current-directory wait shell-type => status

Arguments

command

A string, a list of strings, a simple-vector of strings, or nil .

current-directory

A string. Implemented only on Microsoft Windows.

wait

A boolean.

shell-type

A string or nil .

Values

status

The exit status of the invoked shell or process.

Description

call-system allows executables and DOS or Unix shell commands to be called from Lisp code. The output goes to standard output, as the operating system sees it. (This normally means *terminal-io* in LispWorks.)

If command is a string then it is passed to the shell the command to run without any other arguments. The type of shell to run is determined by shell-type as described below.

If command is a list, then its first element is the command to run directly and the other elements are passed as arguments on the command line (that is, element 0 has its name in argv[0] in C, and so on). If command is a simple-vector of strings, the element at index 0 is the command to run and the other elements are the complete set of arguments seen by the command (that is, element 1 becomes argv[0] in C, and so on). If command is nil , then the shell is run.

On Microsoft Windows current-directory is the lpCurrentDirectory argument passed to CreateProcess . If this is not supplied, the pathname-location of the current-pathname is passed.

If wait is true, call-system does not return until the process has exited. The default for wait is t .

On Unix/Linux/Mac OS X/FreeBSD, if shell-type is a string it specifies the shell. If shell-type is nil (the default) then the Bourne shell, /bin/sh , is used. The C shell may be obtained by passing "/bin/csh" .

On Microsoft Windows if shell-type is nil then cmd.exe is used on Windows Vista, Windows XP and Windows 2000 and command.com on Windows 98 and Windows ME.

call-system returns the exit status of the shell invoked to execute the command on Unix/Linux/Mac OS X, or the process created on Microsoft Windows.

Compatibility Note

The :shell-type argument is not implemented in LispWorks for Windows 4.4 and earlier, and cmd.exe is not used implicity.

LispWorks for Windows 5.0 and later use shell-type cmd.exe (or command.com ) by default when command is a string. The user may see a DOS command window in this case. To call your command directly command should be a list, as in the last example below.

Example

On Unix:

(call-system (format nil "adb ~a < ~a > ~a"
                (namestring   a)
                (namestring   b)
                (namestring   c)))

On Microsoft Windows:

(sys:call-system "sleep 3" :wait t)
 
(sys:call-system '("notepad" "myfile.txt"))
See also

open-pipe
call-system-showing-output
run-shell-command


LispWorks Reference Manual - 12 Mar 2008

NextPrevUpTopContentsIndex