Issue
Many programs return their version number with a command like:
$ program --version
program (platform info) v1.2.3
This is useful for scripting the installation or maintenance of the program, and some other controlled automation magic from System Admins and friends.
Problem
How to easily get the version number for Erlang (OTP)?
On the net
Here are some unsatisfactory solutions (from the trapexit forum and other tutorials/Erlang documentation):
Emulator
$ erl
1> erlang:system_info(otp_release).
"R13B03"
Hard to script. I have not found a way to have erl
execute a single command from a shell prompt.
Release file
$ cat /usr/lib/erlang/releases/RELEASES
[{release,"OTP APN 181 01","R13B03","5.7.4",
[{kernel,"2.13.4","/usr/lib/erlang/lib/kernel-2.13.4"},
{stdlib,"1.16.4","/usr/lib/erlang/lib/stdlib-1.16.4"},
{sasl,"2.1.8","/usr/lib/erlang/lib/sasl-2.1.8"}],
permanent}].
Parsing paradise (with shell).
An alternative could also be checking the install path, but that is not portable (my install path does not include the version, for one).
Personal context: I am writing a script to install the same version of RabbitMQ with plugins on several machines. Some plugins have minimal requirements on the OTP version, and it is how this question started.
Solution
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
Answered By - Odobenus Rosmarus Answer Checked By - Mary Flores (WPSolving Volunteer)