Newbie: Perl script to Windows and Linux executable versions.

H

Harry

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
 
J

Jürgen Exner

Harry said:
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
 
H

Harry

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.
 
R

RedGrittyBrick

Harry said:
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.
 
H

Harry

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.


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


Again, see the FAQ I mentioned above.


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!
 
H

Harry

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)!
 
A

Andrew DeFaria

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 <[email protected]>
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...
 
J

Jürgen Exner

Harry said:
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
 
R

RedGrittyBrick

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)?

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?
 
J

Jürgen Exner

Harry said:
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
 
H

Harry

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.
 
H

Harry

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'?
 
J

J. Gleixner

Harry said:
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?
 
H

Harry

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! :-(
 
H

Harry

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.)
 
H

Harry

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.
 
S

September Storm

Harry said:
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.
 
R

RedGrittyBrick

Harry said:
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.
 
S

Steve C

Harry said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top