D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Unique system identifiers?

 

Hi Grant,

On Mon, Mar 31, 2008 at 02:35:23PM +0100, Grant Sewell wrote:
> I am trying to create a script that can uniquely identify which machine
> it's running on.

By coincidence I had earlier shown someone else a similar trick, and
they urged me to write it up, so here it is:

http://strugglers.net/~andy/blog/2008/04/01/sleeping-deterministically-in-a-shell-script/

That is based on IP address though so you may still wish to go the
MAC address route.

#!/bin/bash
printf "%d\n" 0x$(ip link show eth0 | awk '/link\/ether/ { print $2 }' | sed -e 
's/://g')

or just:

ip link show eth0 | awk '/link\/ether/ { print $2 }' | sed -e 's/://g'

if a hex string is okay.

Cheers,
Andy

-- 
http://bitfolk.com/ -- No-nonsense VPS hosting
Encrypted mail welcome - keyid 0x604DE5DB

Attachment: signature.asc
Description: Digital signature

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html