[erlang-questions] Use of uuidgen with a mnesia application
Fri Jun 6 17:53:52 CEST 2008
Yes, I agree it would be better.
Actually, there is a mistake in my code: it is necessary to add a
lists:sublist(Result,36) because cmd returns the command with the
trailing carriage return!
From what I see by googling uuid erlang, it seems like this could be
a welcome addition to the basic erlang package.
Le 6 juin 08 à 17:29, Anders Nygren a écrit :
> On Fri, Jun 6, 2008 at 9:43 AM, Alexander Lamb
> <> wrote:
>> I need to generate ids to be used as mnesia keys which will be unique
>> not only withing a cluster of Erlang nodes but also globally (e.g.
>> be read from a Java program).
>> I initially thought of writing my own uuidgen function, but it seems
>> like reading the mac address of network interfaces can be rather
>> cumbersom depending on systems.
>> So I decided to use uuidgen from the system and convert it to binary
>> (for efficiency).
>> Is this the correct way of doing things:
>> verify_guuid(Value) ->
>> A = lists:nth(9,Value),
>> B = lists:nth(14,Value),
>> C = lists:nth(19,Value),
>> case [A,B,C] of
>> "---" -> true;
>> _ -> false
>> make_guuid() ->
>> First = os:cmd("uuidgen -t"),
>> case verify_guuid(First) of
>> true -> Result = First;
>> false -> Second = os:cmd("uuidgen"),
>> case verify_guuid(Second) of
>> true -> Result =
>> false -> Result =
>> Now, the reason I have this cascade of case is because on Linux (our
>> Ubuntu servers) it recognizes the -t option to generate the uuid and
>> on MacOSX (our dev machines) it does not.
> Wouldn't it be "nicer" to use os:type/0 and os:version/0 to detect
> what system You are running on?
>> Call me crazy, but I never feel confortable about using a totally
>> random uuid to identity medical records that might be copied from
>> system to system, exported, etc... even if the probability of
>> collision is lower than that of a large asteroid hitting earth!
>> What is your strategy for this (maybe this is a question to ask the
>> couchdb developers, since they use guuids to identify the documents)?
>> Alexander Lamb
>> Founding Associate
>> RODANOTECH Sàrl
>> 4 ch. de la Tour de Champel
>> 1206 Geneva
>> Tel: 022 347 77 37
>> Fax: 022 347 77 38
>> erlang-questions mailing list
More information about the erlang-questions