Next: , Previous: , Up: System Interface   [Contents][Index]


58.3 Operating System Environment

SXEmacs provides access to variables in the operating system environment through various functions. These variables include the name of the system, the user’s UID, and so on.

Variable: system-type

The value of this variable is a symbol indicating the type of operating system SXEmacs is operating on. Here is a table of the possible values:

aix-v3

AIX.

berkeley-unix

Berkeley BSD.

dgux

Data General DGUX operating system.

gnu

A GNU system using the GNU HURD and Mach.

hpux

Hewlett-Packard HPUX operating system.

irix

Silicon Graphics Irix system.

linux

A GNU system using the Linux kernel.

next-mach

NeXT Mach-based system.

rtu

Masscomp RTU, UCB universe.

unisoft-unix

UniSoft UniPlus.

usg-unix-v

AT&T System V.

xenix

SCO Xenix 386.

We do not wish to add new symbols to make finer distinctions unless it is absolutely necessary! In fact, we hope to eliminate some of these alternatives in the future. We recommend using system-configuration to distinguish between different operating systems.

Variable: system-configuration

This variable holds the three-part configuration name for the hardware/software configuration of your system, as a string. The convenient way to test parts of this string is with string-match.

Function: system-name

This function returns the name of the machine you are running on.

(system-name)
     ⇒ "micky.math.tu-berlin.de"
Variable: mail-host-address

If this variable is non-nil, it is used instead of system-name for purposes of generating email addresses. For example, it is used when constructing the default value of user-mail-address. See User Identification. Since this is done when SXEmacs starts up, the value actually used is the one saved when SXEmacs was dumped. See Building SXEmacs.

Command: getenv var &optional interactivep

This function returns the value of the environment variable var, as a string. Within SXEmacs, the environment variable values are kept in the Lisp variable process-environment.

When invoked interactively, getenv prints the value in the echo area.

(getenv "USER")
     ⇒ "lewis"
lewis@slug[10] % printenv
PATH=.:/user/lewis/bin:/usr/bin:/usr/local/bin
USER=lewis
TERM=ibmapa16
SHELL=/bin/csh
HOME=/user/lewis
Command: setenv variable &optional value unset

This command sets the value of the environment variable named variable to value. Both arguments should be strings. This function works by modifying process-environment; binding that variable with let is also reasonable practice.

Variable: process-environment

This variable is a list of strings, each describing one environment variable. The functions getenv and setenv work by manipulating this variable.

process-environment
⇒ ("l=/usr/stanford/lib/gnuemacs/lisp"
    "PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin"
    "USER=lewis"
    "TERM=ibmapa16"
    "SHELL=/bin/csh"
    "HOME=/user/lewis")
Variable: path-separator

This variable holds a string which says which character separates directories in a search path (as found in an environment variable). Its value is ":" for Unix and GNU systems.

Variable: invocation-name

This variable holds the program name under which SXEmacs was invoked. The value is a string, and does not include a directory name.

Variable: invocation-directory

This variable holds the directory from which the SXEmacs executable was invoked, or perhaps nil if that directory cannot be determined.

Function: load-average &optional use-floats

This function returns a list of the current 1-minute, 5-minute and 15-minute load averages. The values are integers that are 100 times the system load averages. The load averages indicate the number of processes trying to run.

When optional use-floats is non-nil, floats will be returned instead of integers. These floats are not multiplied by 100.

(load-average)
     ⇒ (169 158 164)
(load-average t)
     ⇒ (1.69921875 1.58984375 1.640625)
lewis@rocky[5] % uptime
  8:06pm  up 16 day(s), 21:57,  40 users,
 load average: 1.68, 1.59, 1.64

If the 5-minute or 15-minute load averages are not available, return a shortened list, containing only those averages which are available.

On some systems, this function may require special privileges to run, or it may be unimplemented for the particular system type. In that case, the function will signal an error.

Function: emacs-pid

This function returns the process ID of the SXEmacs process.


Next: , Previous: , Up: System Interface   [Contents][Index]