XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next


Type:   -   function (subr)
Source:   -   msstuff.c, osdefs.h, osptrs.h


(system command)
command - the OS command string to be executed
returns -  T  if the command was successful, the error code otherwise


The 'system' function will send the 'command' string to the underlying operating system for execution. After execution of the 'command', the 'system' function will return a  T  result if the 'command' was successful. If the 'command' was not successful, the numeric error code will be returned. Any output from the 'command' execution will not be put in the transcript file.


(system "dir")     ; do a PC directory listing
(system "mycmd")   ; execute a special command

Nyquist: with Nyquist 2.36, the 'system' function works with UNIX and UNIX-like systems but not with Windows, where it just returns NIL.

Note: This function is an extension of the XLISP system. It is provided in the 'msstuff.c' source code file. If your XLISP system is built for an IBM PC and compatibles or generic MS-DOS, this function will work. If your system is built on UNIX or some other operating system, it is unlikely that these functions will work unless you extend the appropriate 'stuff.c' file [which may be called something different like 'unixstuff.c']. The source that could be put in the appropriate 'stuff.c' file for this extension to work on a UNIX style system is:

/* xsystem - execute a system command */

LVAL xsystem()
    char *cmd="COMMAND";
    if (moreargs())
        cmd = (char *)getstring(xlgastring());
    return (system(cmd) == 0 ? true : cvfixnum((FIXTYPE)errno));

The source that gets added to the 'osdefs.h' file is:

extern LVAL xsystem();

The source that gets added to the 'osptrs.h' file is:

{ "SYSTEM", S, xsystem },

See the system function in the XLISP 2.0 manual.

  Back to Top

XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next