Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Get unique value from computer

by welle (Beadle)
on Apr 01, 2011 at 10:04 UTC ( #896846=perlquestion: print w/replies, xml ) Need Help??
welle has asked for the wisdom of the Perl Monks concerning the following question:


I hope that my question is not that stupid.

I'm trying to implement a very very basic way to control where (on which computer) a perl script (.exe) can be run. For this reason I'd like to read a stable unique value from the computer (it doesn't matter what, it just should not change overt time). Maybe some hardware information? A SN? I would check against this value to see if the software can run on this machine.

Now, what kind of unique/stable value can be easily picked up using a pure perl script? Any idea would be much appreciated so that I can better direct my searchings!

Replies are listed 'Best First'.
Re: Get unique value from computer
by Ratazong (Monsignor) on Apr 01, 2011 at 10:15 UTC

      Thankyou for your suggestions. I think I'll go for the MAC Adress. This seems to me a viable solution (and a relative stable value overtime).


        Just to be clear, people could change their MAC address, or get the Perl source of your executable and alter hardcoded values. Perhaps worth keeping in mind depending on what you're shipping.

Re: Get unique value from computer
by marto (Bishop) on Apr 01, 2011 at 10:21 UTC

    "(it doesn't matter what, it just should not change overt time)"

    Things such as MAC address, CPU ID may change if replaced (for example if replaced due to failure/upgrade). Something to consider if you plan on hardcoding this.

Re: Get unique value from computer
by sundialsvc4 (Abbot) on Apr 01, 2011 at 13:23 UTC

    If it were me, I would simply look for and adopt someone else’s license enforcement mechanism, and leave it at that.   I do, in fact, sell a commercial product (tho’ not in Perl), and my experience has been that you can spend just as much time as you care to spend, imagining how everyone on the planet must, surely, be stealing copies of your stuff (and going to very great lengths to do so).   “Did it ever occur to you that maybe the reason why people aren’t buying it is because your product sucks?”   :-}   You are quite likely to lose customers and prospects if you make your mechanism obnoxious.   (For example, I have a standing rule:   “No dongles, or No Sale.   No exceptions.”)

    The most important aspect of a serial-number control mechanism is simply that, “it exists.”   I vividly remember how a friend of mine kept an expensive guitar in a cardboard case secured by the tiniest padlock imaginable.   It was, he said, “to keep the honest people out.”

    I have also been told that some purchasing departments, especially of governments, are not allowed to pay (public) money for something if its benefits can be obtained without a per-unit purchase... hence, there had to be some kind of a serial number, “something that must be bought.”   I always thought this sentiment sounded rather peculiar, so don’t quote me on it.

    Your Mileage May Vary.™

Re: Get unique value from computer
by GrandFather (Sage) on Apr 02, 2011 at 22:29 UTC

    Why? If it's an anti-piracy attempt then whatever you do is only going to block honest or ignorant people. If it's for some other reason you'd probably get better answers if you spell out the details a little.

    True laziness is hard work
Re: Get unique value from computer
by Anonymous Monk on Apr 01, 2011 at 10:11 UTC
    Now, what kind of unique/stable value can be easily picked up using a pure perl script?

    The same type of things that can be picked up using a batch file and built-in commands, and then some other things, see Win32

Re: Get unique value from computer
by ambrus (Abbot) on Apr 01, 2011 at 10:57 UTC

    Make sure that the hole on the diskette doesn't damage the head of the drive, or else you might find yourself in a nasty lawsuit.

Re: Get unique value from computer
by apl (Monsignor) on Apr 01, 2011 at 10:45 UTC
    To prevent hard-coding problems (as mentioned by marto), consider checking for the existence of some unusually named file in a standard directory.

    If the file exists, your program can run; if it doesn't, it won't.

    This gives you the additional flexibility to add machines without having to modify your software.

      Files can be copied from one machine to another ... which reduces their usefulness regarding getting unique values ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://896846]
Approved by marto
and a log crumbles through the grate...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-07-25 05:50 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (363 votes). Check out past polls.