Newbie: Perl script to Windows and Linux executable versions.

Discussion in 'Perl Misc' started by Harry, Sep 18, 2009.

  1. Harry

    Harry Guest

    Hey folks,

    I have a perl script that I'd like to be able to run on Windows and
    Linux. Is this easily possible?

    Here's what I've tried so far... unsuccessfully!

    I've tried to install PAR::packer from CPAN. After having successfully
    installed all its dependencies manually, I discovered that I couldn't
    install PAR::packer itself. I got the message:
    Can't locate ExtUtils/Embed.pm in @INC ...

    I then tried installing ExtUtils/Embed.pm from CPAN. Couldn't. This is
    what I got:
    CPAN.pm: Going to build D/DO/DOUGM/ExtUtils-Embed-1.14.tar.gz
    Writing files for ExtUtils::Embed tests...
    Can't locate ExtUtils/Embed.pm in @INC (@INC contains:

    Not sure what the current recommended method is in the community for
    what I'm trying to do. I'm looking for a 100% free/opensource
    solution. Perl2Exe works but only on Windows and with an irritating a
    few seconds delay on each invocation.

    Regards,
    /HS
     
    Harry, Sep 18, 2009
    #1
    1. Advertising

  2. Harry <> wrote:
    >I have a perl script that I'd like to be able to run on Windows and
    >Linux. Is this easily possible?


    Yes, it is. See "perldoc perlport" for hints about which OS-specific
    functions and features to avoid.
    Basically you need to watch out for the different representations for
    newline and of course using system() or file system specific features is
    a no-no.
    For some areas like parallel programming, process control, networking,
    etc. it can become tricky, too.

    >Here's what I've tried so far... unsuccessfully!


    >I've tried to install PAR::packer from CPAN.


    Why? It has nothing to do with writing cross-platform code.

    >Not sure what the current recommended method is in the community for
    >what I'm trying to do. I'm looking for a 100% free/opensource
    >solution.


    Again, see the FAQ I mentioned above.

    >Perl2Exe works but only on Windows and with an irritating a
    >few seconds delay on each invocation.


    Again, why? It has nothing to do with portable code.

    jue
     
    Jürgen Exner, Sep 18, 2009
    #2
    1. Advertising

  3. Harry

    Harry Guest

    On Sep 18, 8:17 pm, Harry <> wrote:
    > Hey folks,
    >
    > I have a perl script that I'd like to be able to run on Windows and
    > Linux. Is this easily possible?
    >
    > Here's what I've tried so far... unsuccessfully!
    >
    > I've tried to install PAR::packer from CPAN. After having successfully
    > installed all its dependencies manually, I discovered that I couldn't
    > install PAR::packer itself. I got the message:
    >     Can't locate ExtUtils/Embed.pm in @INC ...
    >
    > I then tried installing ExtUtils/Embed.pm from CPAN. Couldn't. This is
    > what I got:
    >       CPAN.pm: Going to build D/DO/DOUGM/ExtUtils-Embed-1.14.tar.gz
    >   Writing files for ExtUtils::Embed tests...
    >   Can't locate ExtUtils/Embed.pm in @INC (@INC contains:
    >
    > Not sure what the current recommended method is in the community for
    > what I'm trying to do. I'm looking for a 100% free/opensource
    > solution. Perl2Exe works but only on Windows and with an irritating a
    > few seconds delay on each invocation.
    >
    > Regards,
    > /HS


    Also, I'm a bit surprised that the standard distribution for a great
    and mature language like Perl doesn't already come with a tool for
    this problem.
     
    Harry, Sep 18, 2009
    #3
  4. Harry wrote:
    >
    > I have a perl script that I'd like to be able to run on Windows and
    > Linux. Is this easily possible?
    >


    1) Yes

    Save your script in an ASCII file with a .pl filename extension. It
    should then run on Linux or Windows.

    Obviously the operating system needs runtime support for Perl, but that
    isn't a problem for most server/desktop/notebook PC operating systems.
    All modern Unix systems and mainstream server/desktop/notebook Linux
    distributions will include perl as part of the normal environment. For
    any Windows platform you have a choice of installable 3rd-party Perl
    runtimes, Activestate Perl for example.


    2) No

    If you want some sort of single executable that runs, without any
    runtime support, on a variety of operating systems (even if they're all
    the same x86 architecture) - I can't think of any programming language
    where this is possible.

    --
    RGB
     
    RedGrittyBrick, Sep 18, 2009
    #4
  5. Harry

    Harry Guest

    On Sep 18, 8:55 pm, Jürgen Exner <> wrote:
    > Harry <> wrote:
    > >I have a perl script that I'd like to be able to run on Windows and
    > >Linux. Is this easily possible?

    >
    > Yes, it is. See "perldoc perlport" for hints about which OS-specific
    > functions and features to avoid.
    > Basically you need to watch out for the different representations for
    > newline and of course using system() or file system specific features is
    > a no-no.
    > For some areas like parallel programming, process control, networking,
    > etc. it can become tricky, too.
    >
    > >Here's what I've tried so far... unsuccessfully!
    > >I've tried to install PAR::packer from CPAN.

    >
    > Why? It has nothing to do with writing cross-platform code.
    >
    > >Not sure what the current recommended method is in the community for
    > >what I'm trying to do. I'm looking for a 100% free/opensource
    > >solution.

    >
    > Again, see the FAQ I mentioned above.
    >
    > >Perl2Exe works but only on Windows and with an irritating a
    > >few seconds delay on each invocation.

    >
    > Again, why? It has nothing to do with portable code.
    >
    > jue


    Jürgen, sorry if I mis-spoke.
    From my already cross-platform Perl script,
    1. I want a Windows .EXE file that I could run on a Windows box
    without any need for a Perl installation.
    2. Likewise, I should be able to have an ELF for the Linux platform.

    Thanks for your quick response!
     
    Harry, Sep 18, 2009
    #5
  6. Harry

    Harry Guest

    On Sep 18, 8:59 pm, RedGrittyBrick <>
    wrote:
    > If you want some sort of single executable that runs, without any
    > runtime support, on a variety of operating systems (even if they're all
    > the same x86 architecture) - I can't think of any programming language
    > where this is possible.


    What I want is
    an EXE for Windows, and
    an ELF for Linux
    each of which runs without any dependence on the Perl installation.

    Thanks, RGB (for taking the time to write)!
     
    Harry, Sep 18, 2009
    #6
  7. body { font: Helvetica, Arial, sans-serif; } p { font: Helvetica, Arial, sans-serif; } .standout { font-family: verdana, arial, sans-serif; font-size: 12px; color: #933; line-height: 13px; font-weight: bold; margin-bottom: 10px; } .code { border-top: 1px solid #ddd; border-left: 1px solid #ddd; border-right: 2px solid #000; border-bottom: 2px solid #000; padding: 5px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: #ffffea; color: black; white-space: pre; font-family: courier; font-size: 12px; -moz-border-radius: 10px; } .terminal { border-top: 10px solid #03f; border-left: 1px solid #ddd; border-right: 2px solid grey; border-bottom: 2px solid grey; padding: 5px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: black; color: white; white-space: pre; font-family: courier; font-size: 12px; -moz-border-radius: 10px; } blockquote id=cite { margin: 1em 0em 1em 0em !important; padding: .25em .25em 0em .25em !important; border-right: 2px solid blue !important; border-left: 2px solid blue !important; } blockquote blockquote id=cite { margin: 0em .25em .25em .25em !important; padding: 0em .25em .25em .25em !important; border-right: 2px solid maroon !important; border-left: 2px solid maroon !important; } blockquote blockquote blockquote id=cite { border-right: 2px solid teal !important; border-left: 2px solid teal !important; } blockquote blockquote blockquote blockquote id=cite { border-right: 2px solid purple !important; border-left: 2px solid purple !important; } blockquote blockquote blockquote blockquote blockquote id=cite { border-right: 2px solid green !important; border-left: 2px solid green !important; } Harry wrote: On Sep 18, 8:59 pm, RedGrittyBrick &lt;&gt;
    wrote:
    If you want some sort of single executable that runs, without any runtime support, on a variety of operating systems (even if they're all the same x86 architecture) - I can't think of any programming language where this is possible.
    What I want is
    an EXE for Windows, and
    an ELF for Linux
    each of which runs without any dependence on the Perl installation.

    Thanks, RGB (for taking the time to write)!
    And I want a car that runs on seawater. Neither will happen in our lifetimes...


    --
    Andrew DeFaria
    You never really learn to swear until you learn to drive.
     
    Andrew DeFaria, Sep 18, 2009
    #7
  8. Harry <> wrote:
    >From my already cross-platform Perl script,
    >1. I want a Windows .EXE file that I could run on a Windows box
    >without any need for a Perl installation.
    >2. Likewise, I should be able to have an ELF for the Linux platform.


    Well, if you need binaries, then Perl may not have been the best choice.
    IMO all tools that create self-containd executable from Perl scripts are
    crutches at best and don't work all that well.

    jue
     
    Jürgen Exner, Sep 18, 2009
    #8
  9. Harry wrote:
    > On Sep 18, 8:17 pm, Harry <> wrote:
    >> Hey folks,
    >>
    >> I have a perl script that I'd like to be able to run on Windows and
    >> Linux. Is this easily possible?
    >>
    >> Here's what I've tried so far... unsuccessfully!
    >>
    >> I've tried to install PAR::packer from CPAN. After having successfully
    >> installed all its dependencies manually, I discovered that I couldn't
    >> install PAR::packer itself. I got the message:
    >> Can't locate ExtUtils/Embed.pm in @INC ...


    Doesn't that mean that you have *not* installed all the dependencies? Or
    at least, not in the right places? Did you install ExtUtils::Embed?
    Isn't that one of the standard modules? What Perl versions are you using
    (perl -v)?


    >>
    >> I then tried installing ExtUtils/Embed.pm from CPAN. Couldn't. This is
    >> what I got:
    >> CPAN.pm: Going to build D/DO/DOUGM/ExtUtils-Embed-1.14.tar.gz
    >> Writing files for ExtUtils::Embed tests...
    >> Can't locate ExtUtils/Embed.pm in @INC (@INC contains:
    >>
    >> Not sure what the current recommended method is in the community for
    >> what I'm trying to do. I'm looking for a 100% free/opensource
    >> solution. Perl2Exe works but only on Windows and with an irritating a
    >> few seconds delay on each invocation.
    >>

    >
    > Also, I'm a bit surprised that the standard distribution for a great
    > and mature language like Perl doesn't already come with a tool for
    > this problem.


    I don't find it a problem! I use the same .pl files in Windows and Linux
    (so long as they don't use OS-specific features/resources)

    I'm a bit confused about what you want. Do you want two separate files,
    one for Windows and one for Linux, where each file can be installed
    (how? self installer?) and run without first installing Perl and it's
    normal collection of standard modules? Why? Do you want to avoid
    explicitly installing perl? Is there some reason you can install you
    program but not perl?

    --
    RGB
     
    RedGrittyBrick, Sep 18, 2009
    #9
  10. Harry <> wrote:
    >Also, I'm a bit surprised that the standard distribution for a great
    >and mature language like Perl doesn't already come with a tool for
    >this problem.


    Perl is an interpreted language and works very well as such. There are
    no compilers to generate executables for tcsh, bash, awk, cmd, ...,
    either.

    jue
     
    Jürgen Exner, Sep 18, 2009
    #10
  11. Harry

    Harry Guest

    On Sep 18, 9:15 pm, RedGrittyBrick <>
    wrote:
    > Harry wrote:
    > >> I've tried to install PAR::packer from CPAN. After having successfully
    > >> installed all its dependencies manually, I discovered that I couldn't
    > >> install PAR::packer itself. I got the message:
    > >>     Can't locate ExtUtils/Embed.pm in @INC ...

    >
    > Doesn't that mean that you have *not* installed all the dependencies? Or
    > at least, not in the right places? Did you install ExtUtils::Embed?
    > Isn't that one of the standard modules? What Perl versions are you using

    Well the original dependencies reported by cpan program were:
    Archive::Zip
    Getopt::ArgvFile
    Module::ScanDeps
    PAR
    PAR::Dist
    I installed them all one by one. Manually. Via cpan. This step was
    successful.

    > (perl -v)?

    I'm using '5.10.0 built for i386-linux-thread-multi' on Fedora 11.

    > I'm a bit confused about what you want. Do you want two separate files,
    > one for Windows and one for Linux, where each file can be installed
    > (how? self installer?) and run without first installing Perl and it's
    > normal collection of standard modules? Why? Do you want to avoid
    > explicitly installing perl? Is there some reason you can install you
    > program but not perl?

    Ok, here's what I want to do. I do have Perl installed both on Windows
    and Linux development machines.
    There is a Perl script that I wrote which I tested that it works fine
    on my Windows and Linux boxes.
    I want to handover this Perl script to another person (outside
    development). This another person could be field personnel, or even a
    customer. I don't want my logic to be leaked to anyone outside my
    development team. Hence the need to have a binary EXE for Windows and
    an ELF for Linux that a non-developer could use without needing to
    install Perl on their machines and, more importantly, without knowing
    what I'm doing inside. Of course, hackers can reverse engineer logic
    from EXE/ELF but I can live with that; I only want to make it
    difficult for casual hackers.
     
    Harry, Sep 18, 2009
    #11
  12. Harry

    Harry Guest

    On Sep 18, 9:14 pm, Jürgen Exner <> wrote:
    > Harry <> wrote:
    > >From my already cross-platform Perl script,
    > >1. I want a Windows .EXE file that I could run on a Windows box
    > >without any need for a Perl installation.
    > >2. Likewise, I should be able to have an ELF for the Linux platform.

    >
    > Well, if you need binaries, then Perl may not have been the best choice.
    > IMO all tools that create self-containd executable from Perl scripts are
    > crutches at best and don't work all that well.


    Really?! That is very disappointing to hear. I was (and am still)
    hoping for a tool that I could point
    to my local Perl installation and
    to my Perl script, which will then
    give me a platform-specific executable (EXE or ELF).

    Basically, what you're saying is commercial programs like Perl2Exe
    don't fully work! Do you have any info on what kind of things may not
    work 'all that well'?
     
    Harry, Sep 18, 2009
    #12
  13. Harry

    J. Gleixner Guest

    Harry wrote:
    > On Sep 18, 8:59 pm, RedGrittyBrick <>
    > wrote:
    >> If you want some sort of single executable that runs, without any
    >> runtime support, on a variety of operating systems (even if they're all
    >> the same x86 architecture) - I can't think of any programming language
    >> where this is possible.

    >
    > What I want is
    > an EXE for Windows, and
    > an ELF for Linux
    > each of which runs without any dependence on the Perl installation.


    java.exe doesn't have any dependence...

    You need to have perl installed if you want to run something written in
    Perl.

    Maybe this is what you're after??

    perldoc -q "How can I get a binary version of perl"

    Complete guess, since probably what you're asking for
    isn't really what you need. What exactly are you trying to do?
     
    J. Gleixner, Sep 18, 2009
    #13
  14. Harry

    Harry Guest

    On Sep 18, 9:17 pm, Jürgen Exner <> wrote:
    > Harry <> wrote:
    > >Also, I'm a bit surprised that the standard distribution for a great
    > >and mature language like Perl doesn't already come with a tool for
    > >this problem.

    >
    > Perl is an interpreted language and works very well as such. There are
    > no compilers to generate executables for  tcsh, bash, awk, cmd,  ...,
    > either.


    I see your point, Jue! :-(
     
    Harry, Sep 18, 2009
    #14
  15. Harry

    Harry Guest

    On Sep 18, 9:32 pm, Harry <> wrote:
    > On Sep 18, 9:17 pm, Jürgen Exner <> wrote:
    >
    > > Harry <> wrote:
    > > >Also, I'm a bit surprised that the standard distribution for a great
    > > >and mature language like Perl doesn't already come with a tool for
    > > >this problem.

    >
    > > Perl is an interpreted language and works very well as such. There are
    > > no compilers to generate executables for  tcsh, bash, awk, cmd,  ....,
    > > either.

    >
    > I see your point, Jue! :-(


    Though, there's a py2exe for Python folks!
    I don't use Python for my work, so, obviously, it's of no use for me.
     
    Harry, Sep 18, 2009
    #15
  16. Harry

    Harry Guest

    On Sep 18, 9:31 pm, "J. Gleixner" <>
    wrote:
    > Harry wrote:
    > > On Sep 18, 8:59 pm, RedGrittyBrick <>
    > > wrote:
    > >> If you want some sort of single executable that runs, without any
    > >> runtime support, on a variety of operating systems (even if they're all
    > >> the same x86 architecture) - I can't think of any programming language
    > >> where this is possible.

    >
    > > What I want is
    > >     an EXE for Windows, and
    > >     an ELF for Linux
    > > each of which runs without any dependence on the Perl installation.

    >
    > java.exe doesn't have any dependence...
    >
    > You need to have perl installed if you want to run something written in
    > Perl.
    >
    > Maybe this is what you're after??
    >
    > perldoc -q "How can I get a binary version of perl"


    Nope. Sorry for my imprecise original description of what I wanted
    (and still want). Could I request you to look at my clarifications to
    other posters of this thread...? otherwise, I'll be duplicating what I
    just now said. (Thanks for taking the time to write.)
     
    Harry, Sep 18, 2009
    #16
  17. Harry

    Harry Guest

    On Sep 18, 9:35 pm, Harry <> wrote:
    > On Sep 18, 9:32 pm, Harry <> wrote:
    >
    > > On Sep 18, 9:17 pm, Jürgen Exner <> wrote:

    >
    > > > Harry <> wrote:
    > > > >Also, I'm a bit surprised that the standard distribution for a great
    > > > >and mature language like Perl doesn't already come with a tool for
    > > > >this problem.

    >
    > > > Perl is an interpreted language and works very well as such. There are
    > > > no compilers to generate executables for  tcsh, bash, awk, cmd,  ....,
    > > > either.

    >
    > > I see your point, Jue! :-(

    >
    > Though, there's a py2exe for Python folks!
    > I don't use Python for my work, so, obviously, it's of no use for me.


    Hey, would this be technically possible? (Don't laugh.)
    1. I get Perl to compile from Perl codebase on my machine.
    2. Drop in my Perl script <somewhere> in the Perl codebase, make a
    call to it from the main() function of Perl interpreter, and then
    finally
    3. Re-build Perl code base.

    The EXE/ELF I now get will have Perl interpreter plus my script. I can
    live with the LONG build times associated with step 1 and 3 above.
     
    Harry, Sep 18, 2009
    #17
  18. Harry wrote:

    > Though, there's a py2exe for Python folks!
    > I don't use Python for my work, so, obviously, it's of no use for me.


    The same problems exist for py2exe as well. Trying to have a tool
    faithfully grab and properly parse interpreted code into something
    usable/workable for a compiled binary isn't the easiest thing. They do
    reasonably okay for what they are expected to do, even if the resulting
    "to be compiled" code is ridiculously unreadable. It can work and
    maybe (depending on what you want it to do) it can work fine for your
    code and resulting program. But, it can't do everything. If you can
    code in C or something for the platforms in question, that would be the
    best route to go. But, try compiling the code and see how well it
    works for you.
     
    September Storm, Sep 18, 2009
    #18
  19. Harry wrote:
    > On Sep 18, 9:35 pm, Harry <> wrote:
    >> On Sep 18, 9:32 pm, Harry <> wrote:
    >>
    >>> On Sep 18, 9:17 pm, Jürgen Exner <> wrote:
    >>>> Harry <> wrote:
    >>>>> Also, I'm a bit surprised that the standard distribution for a great
    >>>>> and mature language like Perl doesn't already come with a tool for
    >>>>> this problem.
    >>>> Perl is an interpreted language and works very well as such. There are
    >>>> no compilers to generate executables for tcsh, bash, awk, cmd, ...,
    >>>> either.
    >>> I see your point, Jue! :-(

    >> Though, there's a py2exe for Python folks!
    >> I don't use Python for my work, so, obviously, it's of no use for me.

    >
    > Hey, would this be technically possible? (Don't laugh.)
    > 1. I get Perl to compile from Perl codebase on my machine.
    > 2. Drop in my Perl script <somewhere> in the Perl codebase, make a
    > call to it from the main() function of Perl interpreter, and then
    > finally
    > 3. Re-build Perl code base.
    >
    > The EXE/ELF I now get will have Perl interpreter plus my script. I can
    > live with the LONG build times associated with step 1 and 3 above.


    I didn't laugh, I seem to recall that, long ago, one way to make perl
    scripts into executables involved creating a memory dump of a running
    perl interpreter.

    `perldoc -q compile` says

    ----------------------------------------------------------------------
    The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ )
    from ActiveState can "Turn your Perl programs into ready-to-run
    executables for HP-UX, *Linux*, Solaris and Windows."

    Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line
    program for converting perl scripts to executable files. It targets both
    Windows and *unix* platforms.
    ----------------------------------------------------------------------
    (my *emphasis*)

    A hop and a skip takes you to a download page
    "Perl2Exe V9.100 for Linux (Jan 18 2008)"

    --
    RGB
     
    RedGrittyBrick, Sep 18, 2009
    #19
  20. Harry

    Steve C Guest

    Harry wrote:
    > On Sep 18, 9:35 pm, Harry <> wrote:
    >> On Sep 18, 9:32 pm, Harry <> wrote:
    >>
    >>> On Sep 18, 9:17 pm, Jürgen Exner <> wrote:
    >>>> Harry <> wrote:
    >>>>> Also, I'm a bit surprised that the standard distribution for a great
    >>>>> and mature language like Perl doesn't already come with a tool for
    >>>>> this problem.
    >>>> Perl is an interpreted language and works very well as such. There are
    >>>> no compilers to generate executables for tcsh, bash, awk, cmd, ...,
    >>>> either.
    >>> I see your point, Jue! :-(

    >> Though, there's a py2exe for Python folks!
    >> I don't use Python for my work, so, obviously, it's of no use for me.

    >
    > Hey, would this be technically possible? (Don't laugh.)
    > 1. I get Perl to compile from Perl codebase on my machine.
    > 2. Drop in my Perl script <somewhere> in the Perl codebase, make a
    > call to it from the main() function of Perl interpreter, and then
    > finally
    > 3. Re-build Perl code base.
    >
    > The EXE/ELF I now get will have Perl interpreter plus my script. I can
    > live with the LONG build times associated with step 1 and 3 above.



    Why not include the OS as well? Then you only need one executable for
    each architecture.
     
    Steve C, Sep 18, 2009
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,860
  2. Replies:
    15
    Views:
    510
    Dave Thompson
    Aug 21, 2006
  3. pratap
    Replies:
    20
    Views:
    787
    Flash Gordon
    Mar 7, 2007
  4. Jason Cavett
    Replies:
    8
    Views:
    657
    Sanjay
    May 16, 2007
  5. Replies:
    2
    Views:
    188
    RedGrittyBrick
    Apr 21, 2007
Loading...

Share This Page