Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Compile Perl To Executable

by JackRoss (Initiate)
on Jan 08, 2012 at 15:02 UTC ( #946871=perlquestion: print w/ replies, xml ) Need Help??
JackRoss has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys, I'm Jack, it's my first time here and for my first post I ask for help. Not a nice way to start :D, and soon I hope to contribute to this forum. I'm try to convert this for a friend
#!/usr/bin/perl # # pwgen 1.0 # # Usage: pwgen [length] # # length - an optional argument indicating the length of the +password # # This will generate random passwords of the specified or default leng +th. # Requires the Perl package Math::Random::Secure to produce # cyptographically secure passwords. # # Copyright (C) 2012 - Paul E. Jones <paulej@packetizer.com> # Permission to use, copy, modify and distribute this software is gran +ted. # use strict; use Math::Random::Secure qw(irand); # Define the default password length $main::default_password_length = 12; # # GeneratePassword # # Description # This routine will generate a password and return it as a str +ing. # By default, it will not utilize special characters like "~" +in # passwords, but if the second argument is a 1, it will. Note + that # use of special characters provides only minimum additional s +trenth, # yet they are not very friendly for humans. For details, visi +t # https://secure.packetizer.com/pwgen/. # # Parameters # length [in] # The length of the password # special [in] # Indicates whether to use special characters other than # the letters A-Z, a-z, and digits 0-9. # # Returns # A string containing the password, or an empty string if ther +e # was an error producing the password. # sub GeneratePassword { my ($length, $special) = @_; my $password = ""; my @pwchars = ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c +', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q +', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E +', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S +', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '~', '`', '!', '@', '#', '$', '% +', '^', '&', '*', '(', ')', '_', '+', '=', '-', '{', '}', '|', '\\', ' +]', '[', ':', '"', '\'', ';', '<', '>', '?', '/', '.' ); while($length > 0) { if ($special == 1) { $password .= $pwchars[irand(93)]; } else { $password .= $pwchars[irand(62)]; } $length--; } return $password; } # # MAIN # { my $password_length; # # Grab the requested password length from the command-line # if ($#ARGV == 0) { $password_length = $ARGV[0]; if (!($password_length > 0)) { $password_length = $main::default_password_length; } } else { $password_length = $main::default_password_length; } # We will not utilize special char print GeneratePassword($password_length,0) . "\n"; }
I'm noob, I admit. if someone is kind enough to compile and post it, I would be very grateful. Thank you in advance, Jack

Original contents restored above by GrandFather

Hi guys, I'm Jack, it's my first time here and for my first post I ask for help. Not a nice way to start :D, and soon I hope to contribute to this forum. I'm try to convert this for a friend
Code
I'm noob, I admit. if someone is kind enough to compile like Windows .exe and post it, I would be very grateful. Thank you in advance, Jack

Comment on Compile Perl To Executable
Select or Download Code
Re: Someone please give me a hand?
by Tanktalus (Canon) on Jan 08, 2012 at 15:11 UTC

    Convert it to what? It's already perl, you should be able to just run it, after you've installed perl itself. If you're on Windows, and you can't upgrade your OS to Linux, try Strawberry Perl. Download it, install it, and possibly install the extra module (I suspect "cpan -i Math::Random::Secure" has a good chance of working), and then you can just run "perl pwgen" to get your generated password.

    By the way, this site doesn't allow users to attach binary files (or any other files). So, even if we created an executable out of this, we can't post it here.

Re: Someone please give me a hand?
by JackRoss (Initiate) on Jan 08, 2012 at 16:37 UTC
    Ok, listen. I have download this software:
    ActivePerl 5.14.2 Build 1402 ActiveState Perl Dev Kit 9.1.1 Build 295479
    The .pl need this extra library, i have download it with PPM:
    Math-Random-Secure with: Math-Random-Secure depends on Crypt-Random-Source Math-Random-Secure depends on Math-Random-ISAAC Math-Random-Secure depends on Crypt-Random-Source-Strong-Win32 Math-Random-Secure depends on Any-Moose Math-Random-Secure depends on Capture-Tiny Math-Random-Secure depends on namespace-clean Math-Random-Secure depends on Module-Find Math-Random-Secure depends on Devel-Hide Math-Random-Secure depends on B-Hooks-EndOfScope Math-Random-Secure depends on Variable-Magic Math-Random-Secure depends on Crypt-Random-Source Math-Random-Secure depends on Math-Random-ISAAC Math-Random-Secure depends on Crypt-Random-Source-Strong-Win32 Math-Random-Secure depends on Any-Moose Math-Random-Secure depends on Capture-Tiny Math-Random-Secure depends on namespace-clean Math-Random-Secure depends on Module-Find Math-Random-Secure depends on Devel-Hide Math-Random-Secure depends on B-Hooks-EndOfScope Math-Random-Secure depends on Variable-Magic
    Now if i open CMD and set the path of the .pl, the software works fine, but i need an executable. So i'm open the PerlDevKit - PerlApp Select the script - then --> File - Make executable Give me error: Math\Random\ISAAC\XS.pm Then i have download it with PPM Reclick on --> File - Make executable No error but if i'm open the exe i have this:
    PerlApp 9.1.1 build 295479 Copyright (C) 1998-2011 ActiveState Software Inc. All rights reserved. Trial license (Expires: 2012-01-29) ********************************************************************** +****** * WARNING: Applications generated by this evaluation copy of PerlApp w +ill * * stop working after the end of the evaluation period: 2012-0 +1-29 * ********************************************************************** +****** Created 'pwgen.exe' [Test it] Executable size: 1.57 MB, 4 KB larger than last time (0%) [DONE] {.\pwgen.exe} Can't locate Crypt/Random/Source/Strong.pm in @INC (@INC contains: ). +at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.exe>Class/MOP +.pm line 135 Class::MOP::load_first_existing_class('Crypt::Random::Source::Stro +ng') called at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.e +xe>Class/MOP.pm line 140 Class::MOP::load_class('Crypt::Random::Source::Strong', undef) cal +led at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.exe>Moose +/Meta/Class.pm line 554 Moose::Meta::Class::superclasses(undef, 'Crypt::Random::Source::St +rong', 'Crypt::Random::Source::Base') called at /<C:\Documents and Se +ttings\Windows Xp\Desktop\pwgen.exe>Moose.pm line 61 Moose::extends('Moose::Meta::Class=HASH(0x2607b2c)', 'Crypt::Rando +m::Source::Strong', 'Crypt::Random::Source::Base') called at /<C:\Doc +uments and Settings\Windows Xp\Desktop\pwgen.exe>Moose/Exporter.pm li +ne 356 Moose::extends('Crypt::Random::Source::Strong', 'Crypt::Random::So +urce::Base') called at /<C:\Documents and Settings\Windows Xp\Desktop +\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm line 10 eval '' called at perlapp line 848 PerlApp::safe_eval() called at perlapp line 948 PerlApp::my_require('Crypt/Random/Source/Strong/Win32.pm') called +at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.exe>if.pm lin +e 13 if::work(undef, undef, 'Crypt::Random::Source::Strong::Win32') cal +led at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.exe>Math/ +Random/Secure/RNG.pm line 9 Math::Random::Secure::RNG::BEGIN() called at /<C:\Documents and Se +ttings\Windows Xp\Desktop\pwgen.exe>Crypt/Random/Source/Strong/Win32. +pm line 0 eval {...} called at /<C:\Documents and Settings\Windows Xp\Deskto +p\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm line 0 eval '' called at perlapp line 848 PerlApp::safe_eval() called at perlapp line 948 PerlApp::my_require('Math/Random/Secure/RNG.pm') called at /<C:\Do +cuments and Settings\Windows Xp\Desktop\pwgen.exe>Math/Random/Secure. +pm line 8 Math::Random::Secure::BEGIN() called at /<C:\Documents and Setting +s\Windows Xp\Desktop\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm li +ne 0 eval {...} called at /<C:\Documents and Settings\Windows Xp\Deskto +p\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm line 0 eval '' called at perlapp line 848 PerlApp::safe_eval() called at perlapp line 948 PerlApp::my_require('Math/Random/Secure.pm') called at pwgen.pl li +ne 18 main::BEGIN() called at /<C:\Documents and Settings\Windows Xp\Des +ktop\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm line 0 eval {...} called at /<C:\Documents and Settings\Windows Xp\Deskto +p\pwgen.exe>Crypt/Random/Source/Strong/Win32.pm line 0 BEGIN failed--compilation aborted at /<C:\Documents and Settings\Windo +ws Xp\Desktop\pwgen.exe>Math/Random/Secure/RNG.pm line 9, <DATA> line + 166. BEGIN failed--compilation aborted at /<C:\Documents and Settings\Windo +ws Xp\Desktop\pwgen.exe>Math/Random/Secure.pm line 8, <DATA> line 166 +. BEGIN failed--compilation aborted at pwgen.pl line 18, <DATA> line 166 +. [DONE]
    I don't know how do, please give me an advice. Thanks

      Just start by tackling the first error message, which is

      Can't locate Crypt/Random/Source/Strong.pm in @INC (@INC contains: ). +at /<C:\Documents and Settings\Windows Xp\Desktop\pwgen.exe>Class/MOP +.pm line 135

      You are missing the package Crypt::Random::Source::Strong, which in this case you'll find in PPM in the module Crypt-Random-Source, so typing in cmd.exe the following command should fix that problem:

      ppm install Crypt-Random-Source

      Now, try the Perl script again, and look at the first error message again. Another missing module? Install that as well and keep going until you either have a different problem you can't solve (click reply on this post so i get notified) or the script works.

      Before i forget, you did read this

      ********************************************************************** +****** * WARNING: Applications generated by this evaluation copy of PerlApp w +ill * * stop working after the end of the evaluation period: 2012-0 +1-29 * ********************************************************************** +******
      in the output, didn't you. What you have is an evaluation product of a commercial software. So, after you got your script working, you'll have to decide if you want to buy the product or switch to something like Strawberry Perl and PAR.

      "Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupidů and I went ahead anyway." (Crow in "MST3K The Movie")
Re: Someone please give me a hand?
by cavac (Chaplain) on Jan 08, 2012 at 16:48 UTC

    First of all, could you read the following two articles?

    • 341118 How do I compose an effective node title?
    • 174051 How do I post a question effectively?
    Formulating a better title and asking the questions more clearly would make it much esaier for us to help you.

    Second, if you want work with Perl on Windows, there are multiple options. Here are the ones i think a beginner should use:

    I personally use ActivePerl (free) with the full (commercial) development tools (ActivePerl Pro Studio), which is most likely a little overkill for a beginner. You'd probably be better off using Strawberry Perl.

    As for compiling the script to an EXE: It's better you learn how to do that yourself: Take a look at The Win32 Perl Wiki for an overview of available tools. What you want to use for compiling is probably something like PAR.

    "This node was sponsored by the NodeReaper, the best source negative XP available on PerlMonks."
      I have try PAR, and i have this error:
      C:\Documents and Settings\Windows Xp>"C:\Documents and Settings\Window +s Xp\Deskt op\PAR-1.002\Makefile.PL" "C:\Documents and Settings\Windows Xp\Deskto +p\PAR-1.00 2\pwgen.pl" Can't call method "load_all_extensions" on an undefined value at C:/Pe +rl/site/li b/Module/Install.pm line 206. BEGIN failed--compilation aborted at C:\Documents and Settings\Windows + Xp\Deskto p\PAR-1.002\Makefile.PL line 4.
      I don't know how many hour i try to convert this file Thanks for support

        Are you sure you didn't mix incompatible versions of perl and PAR? Check out this compatibility list in the PAR wiki.

        "Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupidů and I went ahead anyway." (Crow in "MST3K The Movie")
Re: Compile Perl To Executable
by JackRoss (Initiate) on Jan 08, 2012 at 17:54 UTC
    Perl version of the file is 5.014002 And the moduce Crypt is installed and working Give me a little favor, can you try to convert the pl on exe and explain me the correct procedure? If you don't want I thank you anyway.

      First of all, as you probably know yet, you don't need to convert a perl script to binary in order to execute this script. Your script "IS executable" just now as long as your system has Perl installed. If your script don't run still, to convert it to a binary probably will not help. If you need a module install this module before.

      Second, convert to... what?. You probably want to look at one of these: Perl2Exe, Perl Archiving Toolkit (PAR), perlcc (convert to c) or Perl Dev Kit, but ...

      ... you could find interesting this node also.

Re: Compile Perl To Executable
by Anonymous Monk on Jan 08, 2012 at 20:29 UTC
Re: Compile Perl To Executable
by JackRoss (Initiate) on Jan 09, 2012 at 09:43 UTC
    Al little update, i'm try to use:
    ActivePerl 5.12.4 Build 1205 Perl2Exe V10.40B for Windows 32-bit
    Load all module, test it on cmd and the file .pl work, so try to convert in Perl2Exe ( just for see if work with another software ), conversion complete. I'm opening the exe and i have this error:
    Unable to locate Mouse or Moose in INC at PERL2EXE_STORAGE/Any/Moose.p +m line 41. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Use of uninitialized value $Any::Moose::PREFERRED in string eq at PERL +2EXE_STORA GE/Any/Moose.pm line 197. Undefined subroutine &Class::MOP::get_metaclass_by_name called at PERL +2EXE_STORA GE/Any/Moose.pm line 111. BEGIN failed--compilation aborted at PERL2EXE_STORAGE/Math/Random/Secu +re/RNG.pm line 5. Compilation failed in require at PERL2EXE_STORAGE/Math/Random/Secure.p +m line 8. BEGIN failed--compilation aborted at PERL2EXE_STORAGE/Math/Random/Secu +re.pm line 8. Compilation failed in require at C:\Documents and Settings\Windows Xp\ +Desktop\Pa ssGen.exe line 18. BEGIN failed--compilation aborted at C:\Documents and Settings\Windows + Xp\Deskto p\PassGen.exe line 18. This exe file was created with the evaluation version of Perl2Exe. For more information visit http://www.indigostar.com (The full version does not display this message with a 2 second delay. +) ...
    Don't find a module Any::Moose. So i'll add at the end of the file:
    #perl2exe_include "C:\Perl\site\lib\Any\Moose.pm";
    Nothing to do, same error. Try Cava Packager, "Success _ Scan No error _ Build Complete" and many error on .exe:
    Could not load class (Mouse::Meta::Method::Delegation) because : Can't + locate Mo use/Meta/Method/Delegation.pm in @INC (@INC contains: Cava::Packager:: +Loader=HAS H(0xa4ece4) C:/DOCUME~1/WINDOW~1/Desktop/PassGen/installer/MyApp/lib/s +td) at C:/ DOCUME~1/WINDOW~1/Desktop/PassGen/installer/MyApp/lib/std/Mouse/Util.p +m line 261 . at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/installer/MyApp/lib/std/Mouse +/Util.pm l ine 270 Mouse::Util::load_class('Mouse::Meta::Method::Delegation') cal +led at C:/ DOCUME~1/WINDOW~1/Desktop/PassGen/installer/MyApp/lib/std/Mouse/Meta/A +ttribute.p m line 339 Mouse::Meta::Attribute::_make_delegation_method('Mouse::Meta:: +Attribute= HASH(0xd2d91c)', 'new_weak', 'new') called at C:/DOCUME~1/WINDOW~1/Des +ktop/PassG en/installer/MyApp/lib/std/Mouse/Meta/Attribute.pm line 280 Mouse::Meta::Attribute::install_accessors('Mouse::Meta::Attrib +ute=HASH(0 xd2d91c)') called at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/installer/My +App/lib/st d/Mouse/Meta/Class.pm line 241 Mouse::Meta::Class::add_attribute('Mouse::Meta::Class=HASH(0xe +2262c)', ' weak_source', 'isa', 'ClassName', 'is', 'rw', 'lazy_build', 1, 'cleare +r', ...) c alled at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/installer/MyApp/lib/std/ +Mouse.pm l ine 52 Mouse::has('weak_source', 'isa', 'ClassName', 'is', 'rw', 'laz +y_build', 1, 'clearer', 'clear_weak_source', ...) called at C:/DOCUME~1/WINDOW~1 +/Desktop/P assGen/installer/MyApp/lib/std/Crypt/Random/Source/Factory.pm line 40 require Crypt/Random/Source/Factory.pm called at C:/DOCUME~1/W +INDOW~1/De sktop/PassGen/installer/MyApp/lib/std/Math/Random/Secure/RNG.pm line 7 Math::Random::Secure::RNG::BEGIN() called at C:/DOCUME~1/WINDO +W~1/Deskto p/PassGen/installer/MyApp/lib/std/Crypt/Random/Source/Factory.pm line +0 eval {...} called at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/inst +aller/MyAp p/lib/std/Crypt/Random/Source/Factory.pm line 0 require Math/Random/Secure/RNG.pm called at C:/DOCUME~1/WINDOW +~1/Desktop /PassGen/installer/MyApp/lib/std/Math/Random/Secure.pm line 8 Math::Random::Secure::BEGIN() called at C:/DOCUME~1/WINDOW~1/D +esktop/Pas sGen/installer/MyApp/lib/std/Crypt/Random/Source/Factory.pm line 0 eval {...} called at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/inst +aller/MyAp p/lib/std/Crypt/Random/Source/Factory.pm line 0 require Math/Random/Secure.pm called at C:/DOCUME~1/WINDOW~1/D +esktop/Pas sGen/installer/MyApp/lib/std/cavaexecscript/PassGen.pl line 18 main::BEGIN() called at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/i +nstaller/M yApp/lib/std/Crypt/Random/Source/Factory.pm line 0 eval {...} called at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/inst +aller/MyAp p/lib/std/Crypt/Random/Source/Factory.pm line 0 require cavaexecscript/PassGen.pl called at <Packaged Modules> +/Applicati on::Loader line 1484 Cava::Pack::Code::_run_packaged_script('cavaexecscript/PassGen +.pl') call ed at <Packaged Modules>/Application::Loader line 1511 Cava::Pack::Code::_run_doscript() called at <Packaged Modules> +/Applicati on::Loader line 1573 Compilation failed in require at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/ +installer/ MyApp/lib/std/Math/Random/Secure/RNG.pm line 7. BEGIN failed--compilation aborted at C:/DOCUME~1/WINDOW~1/Desktop/Pass +Gen/instal ler/MyApp/lib/std/Math/Random/Secure/RNG.pm line 7. Compilation failed in require at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/ +installer/ MyApp/lib/std/Math/Random/Secure.pm line 8. BEGIN failed--compilation aborted at C:/DOCUME~1/WINDOW~1/Desktop/Pass +Gen/instal ler/MyApp/lib/std/Math/Random/Secure.pm line 8. Compilation failed in require at C:/DOCUME~1/WINDOW~1/Desktop/PassGen/ +installer/ MyApp/lib/std/cavaexecscript/PassGen.pl line 18. BEGIN failed--compilation aborted at C:/DOCUME~1/WINDOW~1/Desktop/Pass +Gen/instal ler/MyApp/lib/std/cavaexecscript/PassGen.pl line 18.
    I'm wait for cavac or someone to test the conversion and write a little tutorial for me. I need the .exe for deploy, i can't install on every machine Perl. Thanks for support

      Nothing to do, same error. I'm wait for someone to test the conversion and write a little tutorial for me

      All aforementioned tools come with tutorials :D

      "I'm wait for cavac or someone to test the conversion and write a little tutorial for me. I need the .exe for deploy, i can't install on every machine Perl. Thanks for support"

      While I wont write a tutorial for you, I can confirm I created an exe using pp with Strawberry Perl running on Windows XP, it executes without any errors. I'd suggest you read and understand the pp documentation, especially the 'example' section at the start.

        Thanks marto, Yesterday i have try to use pp without success:
        Can't call method "load_all_extensions" on an undefined value at C:/Pe +rl/site/lib/Module/Install.pm line 206. BEGIN failed--compilation aborted at C:\Documents and Settings\Windows + Xp\Desktop\PAR-1.002\Makefile.PL line 4.
        I need to follow a tutorial/guide for this, we'll see if finally i resolve this issue. Thanks again

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-09-21 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls