Credits Overview Plotting Styles Commands Terminals

system

Syntax:

      system "command string"
      ! command string
      output = system("command string")
      show variable GPVAL_SYSTEM

system "command" executes "command" in a subprocess by invoking the operating system's default shell. If called as a function, system("command") returns the character stream from the subprocess's stdout as a string. One trailing newline is stripped from the resulting string if present. See also backquotes.

The exit status of the subprocess is reported in variables GPVAL_SYSTEM_ERRNO and GPVAL_SYSTEM_ERRMSG. Note that if the command string invokes more than one programs, the subprocess may return "Success" even if one of the programs produced an error. E.g. file = system("ls -1 *.plt | tail -1") will return "Success" even if there are no *.plt files because tail succeeds even if ls does not.