4.12.1.21 System functions

Built-in Function: string gethostname ([bool fqn])

Return the host name of this machine.

If the optional fqn is given and is ‘true’, the function will attempt to return fully-qualified host name, by attempting to resolve it using DNS.

Built-in Function: string getdomainname ()

Return the domain name of this machine. Note, that it does not necessarily coincide with the actual machine name in DNS.

Depending on the underlying ‘libc’ implementation, this call may return empty string or the string ‘(none)’. Do not rely on it to get the real domain name of the box mailfromd runs on, use localdomain (see below) instead.

Library Function: string localdomain ()

Return the local domain name of this machine.

This function first uses getdomainname to make a first guess. If it does not return a meaningful value, localdomain calls gethostname(1) to determine the fully qualified host name of the machine, and returns its domain part.

To use this function, require ‘localdomain.mf’ module (see section Modules), e.g.: require localdomain.

Built-in Function: number time ()

Return the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.

Built-in Function: string strftime (string fmt,   number timestamp)
Built-in Function: string strftime (string fmt,   number timestamp, boolean gmt)

Formats the time timestamp (seconds since the Epoch) according to the format specification format. Ordinary characters placed in the format string are copied to the output without conversion. Conversion specifiers are introduced by a ‘%’ character. See section Time and Date Formats, for a detailed description of the conversion specifiers. We recommend using single quotes around fmt to prevent ‘%’ specifiers from being interpreted as Mailfromd variables (See section Literals, for a discussion of quoted literals and variable interpretation within them).

The timestamp argument can be a return value of time function (see above).

For example:

 
strftime('%Y-%m-%d %H:%M:%S %Z', 1164477564)
 ⇒ 2006-11-25 19:59:24 EET
strftime('%Y-%m-%d %H:%M:%S %Z', 1164477564, 1)
 ⇒ 2006-11-25 17:59:24 GMT
Built-in Function: string uname (string format)

This function returns system information formatted according to the format specification format. Ordinary characters placed in the format string are copied to the output without conversion. Conversion specifiers are introduced by a ‘%’ character. The following conversions are defined:

%s

Name of this system.

%n

Name of this node within the communications network to which this node is attached. Note, that it does not necessarily coincide with the actual machine name in DNS.

%r

Kernel release.

%v

Kernel version.

%m

Name of the hardware type on which the system is running.

For example:

 
  uname('%n runs %s, release %r on %m')
    ⇒ "Trurl runs Linux, release 2.6.26 on i686"

Notice the use of single quotes.

Built-in Function: number system (string str)

The function system executes a command specified in str by calling /bin/sh -c string, and returns -1 on error or the return status of the command otherwise.

Built-in Function: void sleep (number seconds)

Sleep for seconds. This function is intended for debugging and experimental purposes.

Built-in Function: number umask (number mask)

Set the umask to mask & 0777. Return the previous value of the mask.