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.
Executes
Examples:
LsOut = os:cmd("ls"), % on unix platform
DirOut = os:cmd("dir"), % on Win32 platform
Note that in some cases, standard output of a command when
called from another program (for example,
These two functions look up an executable program given its
name and a search path, in the same way as the underlying
operating system.
Returns a list of all environment variables.
Each environment variable is given as a single string on
the format
If Unicode file name encoding is in effect (see the
Returns the
If Unicode file name encoding is in effect (see the
Returns the
If Unicode file name encoding is in effect (see the
Returns the process identifier of the current Erlang emulator
in the format most commonly used by the operating system
environment.
Sets a new
If Unicode filename encoding is in effect (see the
On Unix platforms, the environment will be set using UTF-8 encoding if Unicode file name translation is in effect. On Windows the environment is set using wide character interfaces.
Returns current
This time is not a monotonically increasing time.
Returns current
Calling
This time is not a monotonically increasing time.
Returns current
Example of code formatting a string in the format "DD Mon YYYY HH:MM:SS.mmmmmm", where DD is the day of month, Mon is the textual month name, YYYY is the year, HH:MM:SS is the time and mmmmmm is the microseconds in six positions:
-module(print_time).
-export([format_utc_timestamp/0]).
format_utc_timestamp() ->
TS = {_,_,Micro} = os:timestamp(),
{{Year,Month,Day},{Hour,Minute,Second}} =
calendar:now_to_universal_time(TS),
Mstr = element(Month,{"Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec"}),
io_lib:format("~2w ~s ~4w ~2w:~2..0w:~2..0w.~6..0w",
[Day,Mstr,Year,Hour,Minute,Second,Micro]).
The module above could be used in the following way:
1> io:format("~s~n",[print_time:format_utc_timestamp()]). 29 Apr 2009 9:55:30.051711
OS system time can also be retreived by
Returns the current performance counter value in
Returns a performance counter that can be used as a very fast and high resolution timestamp. This counter is read directly from the hardware or operating system with the same guarantees. This means that two consecutive calls to the function are not guaranteed to be monotonic, though it most likely will be. The performance counter till be converted to the resolution passed as an argument.
1> T1 = os:perf_counter(1000),receive after 10000 -> ok end,T2 = os:perf_counter(1000). 176525861 2> T2 - T1. 10004
Returns the
On Unix,
In Windows,
Think twice before using this function. Use the
Deletes the environment variable
If Unicode filename encoding is in effect (see the
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.
Think twice before using this function. If you still need
to use it, always