1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
.TH os 3 "kernel 2.12.3" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
os \- Operating System Specific Functions
.SH DESCRIPTION
.LP
The functions in this module are operating system specific\&. Careless use of these functions will result in programs that will only run on a specific platform\&. On the other hand, with careful use these functions can be of help in enabling a program to run on most platforms\&.
.SH EXPORTS
.LP
.B
cmd(Command) -> string()
.br
.RS
.TP
Types
Command = string() | atom()
.br
.RE
.RS
.LP
Executes \fICommand\fR in a command shell of the target OS, captures the standard output of the command and returns this result as a string\&. This function is a replacement of the previous \fIunix:cmd/1\fR; on a Unix platform they are equivalent\&.
.LP
Examples:
.nf
LsOut = os:cmd("ls"), % on unix platform
DirOut = os:cmd("dir"), % on Win32 platform
.fi
.LP
Note that in some cases, standard output of a command when called from another program (for example, \fIos:cmd/1\fR) may differ, compared to the standard output of the command when called directly from an OS command shell\&.
.RE
.LP
.B
find_executable(Name) -> Filename | false
.br
.B
find_executable(Name, Path) -> Filename | false
.br
.RS
.TP
Types
Name = string()
.br
Path = string()
.br
Filename = string()
.br
.RE
.RS
.LP
These two functions look up an executable program given its name and a search path, in the same way as the underlying operating system\&. \fIfind_executable/1\fR uses the current execution path (that is, the environment variable PATH on Unix and Windows)\&.
.LP
\fIPath\fR, if given, should conform to the syntax of execution paths on the operating system\&. The absolute filename of the executable program \fIName\fR is returned, or \fIfalse\fR if the program was not found\&.
.RE
.LP
.B
getenv() -> [string()]
.br
.RS
.LP
Returns a list of all environement variables\&. Each environment variable is given as a single string on the format \fI"VarName=Value"\fR, where \fIVarName\fR is the name of the variable and \fIValue\fR its value\&.
.RE
.LP
.B
getenv(VarName) -> Value | false
.br
.RS
.TP
Types
VarName = string()
.br
Value = string()
.br
.RE
.RS
.LP
Returns the \fIValue\fR of the environment variable \fIVarName\fR, or \fIfalse\fR if the environment variable is undefined\&.
.RE
.LP
.B
getpid() -> Value
.br
.RS
.TP
Types
Value = string()
.br
.RE
.RS
.LP
Returns the process identifier of the current Erlang emulator in the format most commonly used by the operating system environment\&. \fIValue\fR is returned as a string containing the (usually) numerical identifier for a process\&. On Unix, this is typically the return value of the \fIgetpid()\fR system call\&. On VxWorks, \fIValue\fR contains the task id (decimal notation) of the Erlang task\&. On Windows, the process id as returned by the \fIGetCurrentProcessId()\fR system call is used\&.
.RE
.LP
.B
putenv(VarName, Value) -> true
.br
.RS
.TP
Types
VarName = string()
.br
Value = string()
.br
.RE
.RS
.LP
Sets a new \fIValue\fR for the environment variable \fIVarName\fR\&.
.RE
.LP
.B
type() -> {Osfamily, Osname} | Osfamily
.br
.RS
.TP
Types
Osfamily = win32 | unix | vxworks
.br
Osname = atom()
.br
.RE
.RS
.LP
Returns the \fIOsfamily\fR and, in some cases, \fIOsname\fR of the current operating system\&.
.LP
On Unix, \fIOsname\fR will have same value as \fIuname -s\fR returns, but in lower case\&. For example, on Solaris 1 and 2, it will be \fIsunos\fR\&.
.LP
In Windows, \fIOsname\fR will be either \fInt\fR (on Windows NT), or \fIwindows\fR (on Windows 95)\&.
.LP
On VxWorks the OS family alone is returned, that is \fIvxworks\fR\&.
.SS Note:
.LP
Think twice before using this function\&. Use the \fIfilename\fR module if you want to inspect or build file names in a portable way\&. Avoid matching on the \fIOsname\fR atom\&.
.RE
.LP
.B
version() -> {Major, Minor, Release} | VersionString
.br
.RS
.TP
Types
Major = Minor = Release = integer()
.br
VersionString = string()
.br
.RE
.RS
.LP
Returns the operating system version\&. On most systems, this function returns a tuple, but a string will be returned instead if the system has versions which cannot be expressed as three numbers\&.
.SS Note:
.LP
Think twice before using this function\&. If you still need to use it, always \fIcall os:type()\fR first\&.
.RE
|