# Global System Information

In order to write the most general *Mathematica* programs you will sometimes need to find out global information about the setup under which your program is being run.

Thus, for example, to tell whether your program should be calling functions like NotebookWrite, you need to find out whether the program is being run in a *Mathematica* session that is using the notebook front end. You can do this by testing the global variable $Notebooks.

$Notebooks | whether a notebook front end is being used |

Determining whether a notebook front end is being used.

*Mathematica* is usually used interactively, but it can also operate in a batch mode—say taking input from a file and writing output to a file. In such a case, a program cannot for example expect to get interactive input from the user.

$BatchInput | whether input is being given in batch mode |

$BatchOutput | whether output should be given in batch mode, without labeling, etc. |

Variables specifying batch mode operation.

The *Mathematica* kernel is a process that runs under the operating system on your computer. Within *Mathematica* there are several global variables that allow you to find the characteristics of this process and its environment.

$CommandLine | the original command line used to invoke the Mathematica kernel |

$ParentLink | the MathLink LinkObject specifying the program that invoked the kernel (or Null if the kernel was invoked directly) |

$ProcessID | the ID assigned to the Mathematica kernel process by the operating system |

$ParentProcessID | the ID of the process that invoked the Mathematica kernel |

$UserName | the login name of the user running the Mathematica kernel |

Environment["var"] | the value of a variable defined by the operating system |

Variables associated with the *Mathematica* kernel process.

If you have a variable such as x in a particular *Mathematica* session, you may or may not want that variable to be the same as an x in another *Mathematica* session. In order to make it possible to maintain distinct objects in different sessions, *Mathematica* supports the variable $SessionID, which uses information such as starting time, process ID and machine ID to try to give a different value for every single *Mathematica* session, whether it is run on the same computer or a different one.

$SessionID | a number set up to be different for every Mathematica session |

A unique number different for every *Mathematica* session.

*Mathematica* provides various global variables that allow you to tell which version of the kernel you are running. This is important if you write programs that make use of features that are, say, new in Version 6. You can then check $VersionNumber to find out if these features will be available.

$Version | a string giving the complete version of Mathematica in use |

$VersionNumber | the Mathematica kernel version number (e.g. ) |

$ReleaseNumber | the release number for your version of the Mathematica kernel on your particular computer system |

$CreationDate | the date, in DateList format, on which your particular Mathematica release was created |

Variables specifying the version of *Mathematica* used.

*Mathematica* itself is set up to be as independent of the details of the particular computer system on which it is run as possible. However, if you want to access external aspects of your computer system, then you will often need to find out its characteristics.

$System | a full string describing the computer system in use |

$SystemID | a short string specifying the computer system in use |

$ProcessorType | the architecture of the processor in your computer system |

$MachineType | the general type of your computer system |

$ByteOrdering | the native byte ordering convention on your computer system |

$OperatingSystem | the basic operating system in use |

$SystemCharacterEncoding | the default raw character encoding used by your operating system |

Variables specifying the characteristics of your computer system.

*Mathematica* uses the values of $SystemID to label directories that contain versions of files for different computer systems, as discussed in "Reading and Writing *Mathematica* Files: Files and Streams" and "Portability of *MathLink* Programs". Computer systems for which $SystemID is the same will normally be binary compatible.

$OperatingSystem has values such as or . By testing $OperatingSystem you can determine whether a particular external program is likely to be available on your computer system.

In[1]:= |

Out[1]= |

$MachineAddresses | the list of current IP addresses |

$MachineName | the name of the computer on which Mathematica is running |

$MachineDomains | the current network domains for the computer |

$MachineID | the unique ID assigned by Mathematica to the computer |

Variables identifying the computer on which *Mathematica* is running.

$ActivationKey | the activation key under which Mathematica is running |

$LicenseExpirationDate | the date on which the license expires |

$NetworkLicense | whether this is a network license |

$LicenseServer | the full name of the machine serving the license |

$LicenseProcesses | the number of Mathematica processes currently being run under the license |

$MaxLicenseProcesses | the maximum number of processes provided by the license |

$PasswordFile | password file used when the kernel was started |