Top
Back: 5.1.124 subst
Forward: 5.1.126 syz
FastBack: 5. Functions and system variables
FastForward: 6. Tricks and pitfalls
Up: 5.1 Functions
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

5.1.125 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("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("")

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.

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
// report value of all options
system("--");
→ // --batch           0
→ // --execute
→ // --sdb             0
→ // --echo            0
→ // --help            0
→ // --quiet           0
→ // --random          937848971
→ // --no-tty          0
→ // --user-option
→ // --version         0
→ // --allow-net       0
→ // --browser
→ // --emacs           0
→ // --no-stdlib       0
→ // --no-rc           0
→ // --no-warn         0
→ // --no-out          0
→ // --min-time        "0.5"
→ // --mp-port
→ // --mp-host
→ // --ticks-per-sec   1
→ // --mp-transp
→ // --mp-mode
// set minimal display time to 0.02 seconds
system("--min-time", "0.02");
// set timer resolution to 0.01 seconds
system("--ticks-per-sec", 100);
// re-seed random number generator
system("--random", 12345678);
// allow netscape to access HTML pages from the net
system("--allow-net", 1);
// and set help browser to netscape
system("--browser", "netscape");

Top Back: 5.1.124 subst Forward: 5.1.126 syz FastBack: 5. Functions and system variables FastForward: 6. Tricks and pitfalls Up: 5.1 Functions Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.