Skip to content

Execute Unix Command {R}←⎕SH Y

⎕SH executes a Unix shell or a Microsoft Windows Command Processor. ⎕SH is a synonym of ⎕CMD. Either function cab be used in either environment (Unix or Windows) with the same effect. ⎕SH is probably more natural for the Unix user. This section describes the behaviour of ⎕SH and ⎕CMD under Unix. See Execute Windows Command for a discussion of the behaviour of these system functions under Windows.

The system commands )SH and )CMD provide similar facilities.

Y must be a simple character scalar or vector representing a Unix shell command.  R is a nested vector of character vectors.

Y can be any acceptable Unix command. If the command does not produce any output, R is 0⍴⊂'' but the result is shy. If the command has a non-zero exit code, then APL will signal a DOMAIN ERROR. If the command returns a result and has a zero exit code, then each element of R will be a line from the standard output (stdout) of the command. Output from standard error (stderr) is not captured unless redirected to stdout.

See also ⎕SHELL.

Examples

      ⎕SH'ls'
FILES WS temp
 
      ⎕SH 'rm WS/TEST'
 
      ⎕SH 'grep bin /etc/passwd ; exit 0'
bin:!:2:2::/bin:
 
      ⎕SH 'apl MYWS <inputfile >out1 2>out2 &'

Information

This function is disabled and instead generates a DOMAIN ERROR if the RIDE_SPAWNED parameter is non-zero. This is designed to prevent it being invoked from a Ride session which does not support this type of user interface. For further details, see the Ride User Guide.

⎕SH SH