Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Detecting if Perl is installed and which version

by tomazos (Deacon)
on Mar 24, 2006 at 14:42 UTC ( [id://539031]=perlquestion: print w/replies, xml ) Need Help??

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

I (like many) write Perl scripts to deploy to Windows desktop users.

From my Windows Installer, I would like to automatically detect whether Perl is installed on their machine, and if so which version.

If they don't have Perl installed, I would like my installer to automatically install it.

If they have an old version I would like my installer to automatically upgrade it.

What is the best solution?

-Andrew.

  • Comment on Detecting if Perl is installed and which version

Replies are listed 'Best First'.
Re: Detecting if Perl is installed and which version
by davidrw (Prior) on Mar 24, 2006 at 14:50 UTC
    why not use PAR instead? It will automagically bundle the perl dll and all need modules together for deployment to a perl-less machine.
Re: Detecting if Perl is installed and which version
by inman (Curate) on Mar 24, 2006 at 14:58 UTC
    If I understand your question, you are wanting to detect the presence of the perl.exe executable and then perform an unattended execution of Perl if you don't find one. This should just be a case of trying a command like perl -v and seeing if it executes (in which case, you can test the version) or install a new version.

    The perl.exe location depends on the installation tool that you are using. This doc on unattended installations may be of interest when it comes to adding ActiveState Perl since it uses it as an example.

Re: Detecting if Perl is installed and which version
by radiantmatrix (Parson) on Mar 24, 2006 at 16:52 UTC

    As others have said, PAR is an excellent solution. If you have need to do this often, I've had excellent success with the commercial Perl "compiler" PerlApp, included with the ActiveState PDK. There's a cost, but it works very well and carries support from ActiveState if you ever have problems. If you're doing this for commercial distribution, especially, ActiveState is the way to go.

    With either solution, you don't need to have Perl installed on the target machine, as it (and necessary modules) are packaged together inside the EXE. This carries the added advantage that your users can't break your programs by upgrading (or removing, etc.) their Perl modules.

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet
Re: Detecting if Perl is installed and which version
by Anonymous Monk on Mar 24, 2006 at 14:56 UTC
    If they have an old version I would like my installer to automatically upgrade it.
    Your going to ask the user if they want to upgrade Perl first, right? I would be seriously ticked off if an installer automatically upgraded third party software without asking.
Re: Detecting if Perl is installed and which version
by Anonymous Monk on Mar 24, 2006 at 14:55 UTC
    The best solution is to bundle your own perl, and not mess with anyone elses
Re: Detecting if Perl is installed and which version
by salva (Canon) on Mar 24, 2006 at 15:21 UTC
    remember that to upgrade a perl installation without breaking other apps using it, you may need to reinstall also any modules the user or the other apps had installed.

    As other monks have suggested, it's usually better to use a packer like par.

Re: Detecting if Perl is installed and which version
by tomazos (Deacon) on Mar 24, 2006 at 23:47 UTC
    The trouble with PAR is that it turns my 20k Perl script into a 1MB exe. That seems a bit silly. Now deploy seven different scripts - and you are quickly starting to look pretty stupid shipping an 7MB installer - with 7 different perls. :)

    -Andrew.

      Are your users on a corporate LAN? If so, place perl and your 7 scripts on a share and distribute a 10 line .cmd file that connects to the share and runs the scripts from there.

      If properly configured, you need only add those machines to upgrade to the appropriate user group and they'll run your script automatically on boot, and remove themselves from the group when done.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      Check out the PAR::Tutorial. My interpretation of the section starting "Aggregating multiple programs" is that one need not have a full PAR for each Perl program.

      emc

      " The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
      —Nathaniel S. Borenstein

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://539031]
Approved by inman
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found