Previous Page Next Page Contents

system -- execute a command of the operating system

Introduction

system("command") executes a command of the operating system or a program, respectively.

Call(s)

system("command")

!command

Parameters

"command" - a command of the operating system or a name of a program as a MuPAD character string

Returns

the ``error code'': an integer.

Related Functions

sysname

Details

Example 1

On a UNIX or Linux system, the date command is executed. The command output is printed to the screen, the error code 0 for successful execution is returned to the MuPAD session:

>> errorcode := system("date"):
      Fri Sep 29 14:42:13 MEST 2000
>> errorcode
                                     0

Now the date command is called with the command line option '+%m' in order to display the current month only:

>> errorcode := system("date '+%m'"):
      09

Missing the prefix '+' in the command line option of date, date and therefore system returns an error code. Note that the error output goes to stderr:

>> system("date '%m'")
      date: invalid date '%m'
      
                                     1
>> delete errorcode:

Example 2

The output of a program started with the system command cannot be accessed in MuPAD directly, but it can be redirected into a file and then be read using the read or ftextinput command:

>> system("echo communication example > comm_file"):
   ftextinput("comm_file")
                          "communication example"
>> system("rm -f comm_file"):

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000