Top
Back: subst
Forward: syz
FastBack: Functions and system variables
FastForward: Control structures
Up: Functions
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

5.1.141 system

Syntax:
system ( string_expression )
system ( string_expression, expression )
Type:
depends on the desired function, may be none
Purpose:
interface to internal data and the operating system. The string_expression determines the command to execute. Some commands require an additional argument (second form) where the type of the argument depends on the command. See below for a list of all possible commands.
Note:
Not all functions work on every platform.
Functions:
system("sh", string_expression )
shell escape, returns the return code of the shell as int. The string is sent literally to the shell.
system("pid")
returns the process number as int (for creating unique names).
system("--cpus")
returns the number of cpu cores as int (for using multiple cores).
system("uname")
returns a string identifying the architecture for which SINGULAR was compiled.
system("getenv", string_expression)
returns the value of the shell environment variable given as the second argument. The return type is string.
system("setenv",string_expression, string_expression)
sets the shell environment variable given as the second argument to the value given as the third argument. Returns the third argument. Might not be available on all platforms.
system("tty")
resets the terminal.
system("version")
returns the version number of SINGULAR as int.
system("contributors")
returns names of people who contributed to the SINGULAR kernel as string.
system("gen")
returns the generating element of the multiplicative group of (Z/p)\{0} (as int) where p is the characteristic of the basering.
system("nblocks")
system("nblocks", ring_name )
returns the number of blocks of the given ring, or the number of parameters of the current basering, if no second argument is given. The return type is int.
system("Singular")
returns the absolute (path) name of the running SINGULAR as string.
system("SingularLib")
returns the colon seperated library search path name as string.
system("--")
prints the values of all options.
system("--long_option_name")
returns the value of the (command-line) option long_option_name. The type of the returned value is either string or int. See Command line options, for more info.
system("--long_option_name", expression)
sets the value of the (command-line) option long_option_name to the value given by the expression. Type of the expression must be string, or int. See Command line options, for more info. Among others, this can be used for setting the seed of the random number generator, the used help browser, the minimal display time, or the timer resolution.
system("browsers");
returns a string about available help browsers. See The online help system. returns the number of cpus as int (for creating multiple threads/processes).
system("pid")
Example:
 
// a listing of the current directory:
system("sh","ls");
// execute a shell, return to SINGULAR with exit:
system("sh","sh");
string unique_name="/tmp/xx"+string(system("pid"));
unique_name;
==> /tmp/xx4711
system("uname")
==> ix86-Linux
system("getenv","PATH");
==> /bin:/usr/bin:/usr/local/bin
system("Singular");
==> /usr/local/bin/Singular

Top Back: subst Forward: syz FastBack: Functions and system variables FastForward: Control structures Up: Functions Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 3-1-6, Dec 2012, generated by texi2html.