1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
9
<holder>Ericsson AB, All Rights Reserved</holder>
12
The contents of this file are subject to the Erlang Public License,
13
Version 1.1, (the "License"); you may not use this file except in
14
compliance with the License. You should have received a copy of the
15
Erlang Public License along with this software. If not, it can be
16
retrieved online at http://www.erlang.org/.
18
Software distributed under the License is distributed on an "AS IS"
19
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
20
the License for the specific language governing rights and limitations
23
The Initial Developer of the Original Code is Ericsson AB.
33
<modulesummary>Operating System Specific Functions</modulesummary>
35
<p>The functions in this module are operating system specific.
36
Careless use of these functions will result in programs that will
37
only run on a specific platform. On the other hand, with careful
38
use these functions can be of help in enabling a program to run on
43
<name>cmd(Command) -> string()</name>
44
<fsummary>Execute a command in a shell of the target OS</fsummary>
46
<v>Command = string() | atom()</v>
49
<p>Executes <c>Command</c> in a command shell of the target OS,
50
captures the standard output of the command and returns this
51
result as a string. This function is a replacement of
52
the previous <c>unix:cmd/1</c>; on a Unix platform they are
56
LsOut = os:cmd("ls"), % on unix platform
57
DirOut = os:cmd("dir"), % on Win32 platform</code>
58
<p>Note that in some cases, standard output of a command when
59
called from another program (for example, <c>os:cmd/1</c>)
60
may differ, compared to the standard output of the command
61
when called directly from an OS command shell.</p>
65
<name>find_executable(Name) -> Filename | false</name>
66
<name>find_executable(Name, Path) -> Filename | false</name>
67
<fsummary>Absolute filename of a program</fsummary>
69
<v>Name = string()</v>
70
<v>Path = string()</v>
71
<v>Filename = string()</v>
74
<p>These two functions look up an executable program given its
75
name and a search path, in the same way as the underlying
76
operating system. <c>find_executable/1</c> uses the current
77
execution path (that is, the environment variable PATH on
78
Unix and Windows).</p>
79
<p><c>Path</c>, if given, should conform to the syntax of
80
execution paths on the operating system. The absolute
81
filename of the executable program <c>Name</c> is returned,
82
or <c>false</c> if the program was not found.</p>
86
<name>getenv() -> [string()]</name>
87
<fsummary>List all environment variables</fsummary>
89
<p>Returns a list of all environement variables.
90
Each environment variable is given as a single string on
91
the format <c>"VarName=Value"</c>, where <c>VarName</c> is
92
the name of the variable and <c>Value</c> its value.</p>
96
<name>getenv(VarName) -> Value | false</name>
97
<fsummary>Get the value of an environment variable</fsummary>
99
<v>VarName = string() </v>
100
<v>Value = string()</v>
103
<p>Returns the <c>Value</c> of the environment variable
104
<c>VarName</c>, or <c>false</c> if the environment variable
109
<name>getpid() -> Value </name>
110
<fsummary>Return the process identifier of the emulator process</fsummary>
112
<v>Value = string()</v>
115
<p>Returns the process identifier of the current Erlang emulator
116
in the format most commonly used by the operating system
117
environment. <c>Value</c> is returned as a string containing
118
the (usually) numerical identifier for a process. On Unix,
119
this is typically the return value of the <c>getpid()</c>
120
system call. On VxWorks, <c>Value</c> contains the task id
121
(decimal notation) of the Erlang task. On Windows,
122
the process id as returned by the <c>GetCurrentProcessId()</c>
123
system call is used.</p>
127
<name>putenv(VarName, Value) -> true</name>
128
<fsummary>Set a new value for an environment variable</fsummary>
130
<v>VarName = string() </v>
131
<v>Value = string()</v>
134
<p>Sets a new <c>Value</c> for the environment variable
139
<name>type() -> {Osfamily, Osname} | Osfamily</name>
140
<fsummary>Return the OS family and, in some cases, OS name of the current operating system</fsummary>
142
<v>Osfamily = win32 | unix | vxworks</v>
143
<v>Osname = atom()</v>
146
<p>Returns the <c>Osfamily</c> and, in some cases, <c>Osname</c>
147
of the current operating system.</p>
148
<p>On Unix, <c>Osname</c> will have same value as
149
<c>uname -s</c> returns, but in lower case. For example, on
150
Solaris 1 and 2, it will be <c>sunos</c>.</p>
151
<p>In Windows, <c>Osname</c> will be either <c>nt</c> (on
152
Windows NT), or <c>windows</c> (on Windows 95).</p>
153
<p>On VxWorks the OS family alone is returned, that is
156
<p>Think twice before using this function. Use the
157
<c>filename</c> module if you want to inspect or build
158
file names in a portable way.
159
Avoid matching on the <c>Osname</c> atom.</p>
164
<name>version() -> {Major, Minor, Release} | VersionString</name>
165
<fsummary>Return the Operating System version</fsummary>
167
<v>Major = Minor = Release = integer()</v>
168
<v>VersionString = string()</v>
171
<p>Returns the operating system version.
172
On most systems, this function returns a tuple, but a string
173
will be returned instead if the system has versions which
174
cannot be expressed as three numbers.</p>
176
<p>Think twice before using this function. If you still need
177
to use it, always <c>call os:type()</c> first.</p>