shanu_040 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a cgi scripts and I want it should not run once the subscription of the script expires.Could you please give me some suggestions on what are the possible ways and how can I do that.

Any help would be appropriable.

Thanks

Replies are listed 'Best First'.
Re: License key for script
by mr_mischief (Monsignor) on Sep 04, 2010 at 06:20 UTC

    Depending on exactly what you're asking about something may be possible. What I think you're asking, though, is not likely to do you much good. Please clarify what it is you want.

    Are you wanting to write a program in Perl, distribute the source code to the operators of some web server you don't control, and have it not run once a certain date is past?

    Are you wanting to have a CGI program on your own server you can have stop returning results after a certain amount of time or a certain number of total results?

    Do you want to have users sign up for a web application with a username and password (or some other authentication) and stop authenticating them after some point in time?

    Are you wanting to wrap your Perl program with a compiled binary program that checks some license status then decrypts your program and hands it to the interpreter?

    Any of these has a different answer and different points to discuss from the others. I'm not really sure which it is you're asking, or if you're asking something else entirely.

      I should explain it more clearly, Thanks you have done it form me.

      I am looking for...

      Are you wanting to write a program in Perl, distribute the source code to the operators of some web server you don't control, and have it not run once a certain date is past?

      please help me

        It is unfortunate that is what you need to do, because there really is no satisfactory way to give others access to their own copy of your program and enforce a license restriction on it. This is especially true when you provide the source to them.

        There are some possible workarounds. None of them are pleasant. What's worse is that the workarounds for making your Perl code more secure on a server you don't control still don't make rejecting a license or ending a subscription foolproof as a technical measure. Even a compiled program that decrypts most of itself at run time can be broken by a motivated person with knowledge of readily available tools.

        The only reliable way to enforce subscriptions is to control where the code runs. You can do that by running it on your own server and selling access to it or by enforcing the subscription in a reliable and responsive court system. The latter is often more trouble than it is worth.

Re: License key for script
by CountZero (Bishop) on Sep 04, 2010 at 07:10 UTC
    I would go one step further and actually delete the script if it is run past its period of validity:
    use Acme::Scripticide qw(good_bye_cruel_world); if( subscription_is_expired() ){ good_bye_cruel_world('This script is now no more!'); exit; }
    Testing it is actually a bit difficult! I once lost my 5 line script proving Fermat's last theorem that way.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      I once lost my 5 line script proving Fermat's last theorem that way.
      That's ok, there was a bug in line 3 anyway.
      A script which stops and says
      "You have not paid your monthly subscription fee agreed to when you li +censed this software. Please visit htttp://yoursite.com/payme.html and submit your license f +ee to receive a new run key. You will need your license number, which is XXXX-XXXX-XXXX-XXXX. Thank you. This program will no longer run until the subscription is p +aid"
      makes it clear that YOU NEEDA PAY YOUR BILL, BUCKO and no damage is done, except perhaps to the ego of the person who didn't pay the bill.

      A self-deleting program could be stretched by a sympathetic DA into being a "logic bomb" and therefore prosecuted as illegal - even if it was your right to disable access to the program. This is not a chance to take. Also, you might get sued for loss of income, etc. by the licensee (even if he's in the wrong!) because he had to spend X hours at $LARGENUM per hour making sure your program hadn't damaged your system. Also not a chance to take.

      As mentioned, the only real way to be sure that your client isn't cheating is to host the software somewhere you control and block access if the bills aren't paid. Just hosting the license check won't do, especially in Perl, since the the license check can be removed without damaging the rest of the code.

Re: License key for script
by Anonymous Monk on Sep 04, 2010 at 06:14 UTC
Re: License key for script
by talexb (Chancellor) on Sep 07, 2010 at 02:40 UTC

    You could host the scripts on your server and have your customer hit your server with some sort of subscription identification for each CGI.

    Once the customer's subscription had expired, the script would re-direct to a Not Working page, and a request for a new subscription could be E-Mailed to your customer.

    TMTOWTDI.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds