From owner-freebsd-questions Wed May 24 15: 1:26 2000 Delivered-To: freebsd-questions@freebsd.org Received: from be-well.ilk.org (lowellg.ne.mediaone.net [24.147.184.128]) by hub.freebsd.org (Postfix) with ESMTP id B7D9837B6F8 for ; Wed, 24 May 2000 15:01:22 -0700 (PDT) (envelope-from lowell@be-well.ilk.org) Received: (from lowell@localhost) by be-well.ilk.org (8.9.3/8.9.3) id SAA13590; Wed, 24 May 2000 18:01:20 -0400 (EDT) (envelope-from lowell) From: Lowell Gilbert To: freebsd-questions@freebsd.org Subject: Re: uuidgen or other GUID-generating utility References: <27E4B476932BD211945B00805FE67AF5089DE1E3@lnxdayexch05.lexis-nexis.com> <20000524161737.A2307@dan.emsphone.com> Date: 24 May 2000 18:01:20 -0400 In-Reply-To: Dan Nelson's message of "Wed, 24 May 2000 16:17:37 -0500" Message-ID: <44bt1v7glr.fsf@lowellg.ne.mediaone.net> Lines: 32 X-Mailer: Gnus v5.7/Emacs 20.6 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Dan Nelson 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