Unique identify computer (both Windows and MacOSX)

  • Thread starter Fernando Malard
  • Start date
F

Fernando Malard

Hello,

How can I unique identify the OS where my Ruby code is running?

I can do this using specific Win32 features but I looking for an OS
independent approach...maybe using the HD serial?

Regards,
Fernando.
 
J

Jarmo Pertman

puts RUBY_PLATFORM

Fernando said:
Hello,

How can I unique identify the OS where my Ruby code is running?

I can do this using specific Win32 features but I looking for an OS
independent approach...maybe using the HD serial?

Regards,
Fernando.
 
D

Daniel Berger

puts RUBY_PLATFORM

No, don't use RUBY_PLATFORM because it won't work with JRuby, and
possibly other implementations.

Instead, require "rbconfig", then check Config::CONFIG['host_os'].

Regards,

Dan
 
M

Matt Harrison

Daniel said:
puts RUBY_PLATFORM

No, don't use RUBY_PLATFORM because it won't work with JRuby, and
possibly other implementations.

Instead, require "rbconfig", then check Config::CONFIG['host_os'].

Regards,

Dan

I believe the OP wants to get a unique identifier for each host,
something like a GUID. I have no idea how you would make this cross
platform though, maybe IP address but those change, or HD serial, but
again that's changable...

Windows supports GUIDs inherantly however AFAIK *nix systems don't.

Sorry I don't have a solution.

Matt
 
H

Heesob Park

2009/1/11 Matt Harrison said:
Daniel said:
puts RUBY_PLATFORM

Fernando Malard wrote:

Hello,
How can I unique identify the OS where my Ruby code is running?
I can do this using specific Win32 features but I looking for an OS
independent approach...maybe using the HD serial?
Regards,
Fernando.

No, don't use RUBY_PLATFORM because it won't work with JRuby, and
possibly other implementations.

Instead, require "rbconfig", then check Config::CONFIG['host_os'].

Regards,

Dan

I believe the OP wants to get a unique identifier for each host, something
like a GUID. I have no idea how you would make this cross platform though,
maybe IP address but those change, or HD serial, but again that's
changable...

Windows supports GUIDs inherantly however AFAIK *nix systems don't.

Sorry I don't have a solution.

Matt
If the OP wants the unique ID per computer in cross platform way, the
mac address is one solution.

Try ruby -r macaddr -e' p Mac.addr '

gem install macaddr

Regards,

Park Heesob
 
P

Pascal J. Bourguignon

Heesob Park said:
2009/1/11 Matt Harrison said:
Daniel said:
puts RUBY_PLATFORM

Fernando Malard wrote:

Hello,
How can I unique identify the OS where my Ruby code is running?
I can do this using specific Win32 features but I looking for an OS
independent approach...maybe using the HD serial?
Regards,
Fernando.

No, don't use RUBY_PLATFORM because it won't work with JRuby, and
possibly other implementations.

Instead, require "rbconfig", then check Config::CONFIG['host_os'].

Regards,

Dan

I believe the OP wants to get a unique identifier for each host, something
like a GUID. I have no idea how you would make this cross platform though,
maybe IP address but those change, or HD serial, but again that's
changable...

HD move from one computer to the other. The OP asked for a computer
ID, not a HD ID. The IP addresses identify interfaces. There may be
several or no interface per computer. Which IP address would you use?
Nowadays, most users are behind a NAT with private IP, so this won't
identify anything.

If the OP wants the unique ID per computer in cross platform way, the
mac address is one solution.

Network cards move from computer to the other. Network cards break
down and are changed. MAC addresses are not always stored in ROM,
some cards allow changing the MAC address. And a computer has several
MAC addresses (even if with only one ethernet address, MAC addresses
are also used on Wifi and Firewire).

It's a problem of definition. What do you consider the computer? Is
that the CPU? Is that an installation of the system? Is that some
given configuration of hardware?


If Internet connectivity is assumed, I would propose a server issuing
unique IDs, and a procedure to mark an "OS" like the OP names it,
which would fetch a new unique ID from the server and store it in some
global file. Then the ID would be retrieved from this global file
named for example, /etc/com.gmail.fpmalard.unique-id on unix systems
and something else on the other systems.


If Internet connectivity cannot be assumed, then you would have to
build a unique ID trying to gather specific data and random data to
reduce the probabilities of a collision. There are several web pages
indicating how to build such an ID. The point is that the specific
data about the computer is gathered only when the ID is made, not when
it's used. If you change your hardware configuration, or move your
"OS" to some other hardware, you should be able to keep your ID.
 
F

Fernando Malard

Hello,

First, thank you all for your comments.
In fact the idea is to generate a install ID of my application to use
some kind of a registration system. The user will send me an INSTALL ID
plus a SERIAL and I will return an AUTHORIZATION key.

Most of MS Windows applications get the GUID (UUID) number from the
installed system which is unique from machine to machine. Some combine
this number with HD serial, BIOS identification, etc.

Of course it is almost impossible to build a 100% secure registration
system and as you all said the hardware can be moved from machine to
machine.

My idea is to generate this unique ID from HD serial, mac address and OS
identification(a combination of all these).

Another approach I'm thinking about is to create a platform dependent
executable module which can be called from inside Ruby script and return
the machine GUID. This way for Windows I can create an EXE module, for
Mac I can create an EXEC module and so on.

Any ideas?

Regards,
Fernando.
 
B

Brian Candler

Pascal said:
If Internet connectivity cannot be assumed, then you would have to
build a unique ID trying to gather specific data and random data to
reduce the probabilities of a collision. There are several web pages
indicating how to build such an ID.

There is a uuid gem too.
The point is that the specific
data about the computer is gathered only when the ID is made, not when
it's used. If you change your hardware configuration, or move your
"OS" to some other hardware, you should be able to keep your ID.

But if you store it on the hard drive, then the uid moves with the hard
drive. If you backup and restore to another machine, then you will have
two machines with the same uid.
 
P

Pascal J. Bourguignon

Brian Candler said:
There is a uuid gem too.


But if you store it on the hard drive, then the uid moves with the hard
drive. If you backup and restore to another machine, then you will have
two machines with the same uid.

Yes, exactly. Why would you want to forbid the user to do that. After
all, it's him who pays for that software, no?
 
F

Fernando Malard

Hello,

I think the mac address is acceptable because major of NIC cards today
are onboard and the computer board is the component that has less chance
to be replaced. If the user replace its main board I can generate a new
installation ID for him without any problems.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top