Skip site navigation (1)Skip section navigation (2)
Date:      24 May 2000 18:01:20 -0400
From:      Lowell Gilbert <lowell@world.std.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: uuidgen or other GUID-generating utility
Message-ID:  <44bt1v7glr.fsf@lowellg.ne.mediaone.net>
In-Reply-To: Dan Nelson's message of "Wed, 24 May 2000 16:17:37 -0500"
References:  <27E4B476932BD211945B00805FE67AF5089DE1E3@lnxdayexch05.lexis-nexis.com> <20000524161737.A2307@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Dan Nelson <dnelson@emsphone.com> writes:

> No, FreBSD doesn't have a program to pull the ethernet address and
> print a guid formatted like Linux's "uuidgen -t".  I don't imagine that
> the program would be hard to port to FreeBSD, though.

Well, you could do that from the command line, too, using ifconfig(8)
to get the ethernet address, and date(1) to get the time, and an
assortment of text utilities to grab just the pieces you want.  Ten
minutes gave me the following shell script, which isn't *guaranteed*
to be unique, but the odds are against getting a collision in many
times the remaining life of the universe (of course, so does using jot
-r, but I only wanted to blow ten minutes on this -- note that you
could cut it up and use the data literally instead of doing an md5,
but that would probably take *another* ten minutes I don't feel like
spending):

foo ()
{
baz1=`date +%s`
baz2=`ifconfig -a|grep ether|head -1|cut -f 2-3  -d " "`
bar=`md5 -q -s "$baz1 $baz2"`

a=`echo -n $bar |cut -c 1-8`
b=`echo -n $bar|cut -c 9-12`
c=`echo -n $bar|cut -c 13-16`
d=`echo -n $bar|cut -c 17-20`
e=`echo -n $bar|cut -c 21-32`
echo ${a}-${b}-${c}-${d}-${e}
}




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44bt1v7glr.fsf>