LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-08-2017, 01:47 PM   #1
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 91
Blog Entries: 1

Rep: Reputation: Disabled
how to convert a perl script *.pl to *.exe ?


Hi Folks,

I would have installed different modules in my machine to convert the script.pl to script.exe if I have control over it. But, I do not have the control over installing the modules like PAR, perlcc, perl2exe etc., So,I need help in converting a *.pl script to an executable, the platform I use is Unix Solaris and I am no admin to install any new packages like PAR, perlcc etc.

Tried looking at some of the POD documents which did not help me in any way.

Is there any alternate way to convert *.pl to *.exe with the perl options ?.

Any simple suggestions with module installations would also helps.

Last edited by rpittala; 04-08-2017 at 11:52 PM. Reason: added one more point to request
 
Old 04-09-2017, 01:49 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,524
Blog Entries: 3

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
*.exe is just part of the filename. It could just as meaningfully be *.xyzzy instead.

What exactly are you trying to do with your perl script and which kind of options do you want passed to it? Usually those options are passed as runtime arguments either by you manually in the shell or via a wrapper script or by modifying the perl script's defaults.
 
Old 04-09-2017, 02:48 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,258

Rep: Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457
the perl script itself will be executable if you run chmod +x on it (see man chmod). You do not need to convert it, just set that execute bit. And also add a first line - if not yet made:
Code:
#!/usr/bin/perl
or similar which points to your perl binary.
 
2 members found this post helpful.
Old 04-09-2017, 02:56 AM   #4
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 91

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi Tubocapitalist,

My question was just straight forward as mentioned in the subject line.

let me explain you in detail, I have a perl script and I want to make the same script as an executable package so that when I give my script as an executable to a friend or freelancer they would not be able to look at my code or understand the script. But, they can have the access to the executable package.So, the user will make use of the executable but he can not have the access to the code or modify.

Last edited by rpittala; 04-09-2017 at 03:04 AM.
 
Old 04-09-2017, 03:06 AM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,584
Blog Entries: 11

Rep: Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606Reputation: 3606
What you are asking for is how to compile perl to executable binary.

A quick web search turned up many links, but this looks like the a good place to start.

From that links:

Quote:
Sad ending

So, why did (and does) nobody really use this? Well, it turns out that bytecode loading is indeed faster in some (but not all) cases, but not very reliable: segfaults are quite common, and nobody so far has been able to fix it. In addition, the bytecode files are not portable between systems, or even Perl versions.

But there is another problem with Byteloader. The PMC file is actually just a normal Perl file: via a source filter, the bytecode is loaded. That's nasty, and makes using precompiled bytecode even less interesting.

Thus a sad story seemed to end, and the PMC feature was ignored, forgotten, and almost about to be deprecated... (Features aren't removed lightly in Perl - even if nobody uses it, a deprecation cycle is needed.)
There are other options for doing it as well, but I don't see anything very attractive from a use or maintenance point of view.

Last edited by astrogeek; 04-09-2017 at 03:27 AM.
 
1 members found this post helpful.
Old 04-09-2017, 03:11 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,524
Blog Entries: 3

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
Quote:
Originally Posted by rpittala View Post
Hi Tubocapitalist,

My question was just straight forward as mentioned in the subject line.

let me explain you in detail, I have a perl script and I want to make the same script as an executable package so that when I give my script as an executable to a friend or freelancer they would not be able to look at my code or understand the script. But, they can have the access to the execute the package.So, the user will make use of the executable but he can not have the access to the code or modify.
Scripts, including perl, are executable. See the advice given about chmod. If your goal is blocking the ability to read the source code, you'll want to use a compiled language instead. C, for example, does have PCRE libraries available so that you can continue to use regular expressions. Or else, run your program as a web back-end on a server they only access via a browser.

As far as I know, perl is an interpreted language that seems to compile parts on the fly. Some of the functions are even built around that. So it would not technically possible to compile perl to a static binary such as results from C.

Edit: http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html

About the subject line, it only mentions file names. You are always free to name a file what you want and it has no bearing on any other characteristics.

Last edited by Turbocapitalist; 04-09-2017 at 03:53 AM. Reason: link
 
Old 04-09-2017, 03:47 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 16,914
Blog Entries: 10

Rep: Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039Reputation: 5039
rpittala, this is a question of mentality, not technology.

why do you not want others to look at the code? you should think about that.


a perl script made executable will run on most linux machines, there's no need to "compile" it.

a compiled perl script might run on someone else's machine, if it uses the same architecture & operating system as you. why do that?

this is a linux forum, and gnu/linux is open source. you understand what "open source" means?
personally, i'm suspicious about every piece of software that deliberately hides its source.
 
3 members found this post helpful.
Old 04-09-2017, 03:53 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,587

Rep: Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507Reputation: 3507
Very well said.
 
Old 04-09-2017, 03:58 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,258

Rep: Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457
Quote:
Originally Posted by rpittala View Post
My question was just straight forward as mentioned in the subject line.
no, I do not think so. Or I simply misunderstood.
Quote:
Originally Posted by rpittala View Post
let me explain you in detail, I have a perl script and I want to make the same script as an executable package so that when I give my script as an executable to a friend or freelancer they would not be able to look at my code or understand the script. But, they can have the access to the executable package.So, the user will make use of the executable but he can not have the access to the code or modify.
see the -u option of perl, that will do something like that.
also another option could be to use shc, but not really simple.
 
Old 04-09-2017, 05:18 AM   #10
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 91

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi ondoho,

Quote:
rpittala, this is a question of mentality, not technology.

why do you not want others to look at the code? you should think about that.


a perl script made executable will run on most linux machines, there's no need to "compile" it.

a compiled perl script might run on someone else's machine, if it uses the same architecture & operating system as you. why do that?

this is a linux forum, and gnu/linux is open source. you understand what "open source" means?
personally, i'm suspicious about every piece of software that deliberately hides its source.
Yes, I agree with you as an open source user. But, as an employee of an organisation I have to deal with what the organisation had asked to do and it is vis versa process where the organisation has to deal with their clients.

I suppose, it`s not a question of mentality and it is a question of possibility in opensource as well and we already have the utilities available opensource too.

Last edited by rpittala; 04-09-2017 at 05:31 AM.
 
Old 04-09-2017, 05:36 AM   #11
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,524
Blog Entries: 3

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
What is their official objection if I may ask?
 
Old 04-09-2017, 05:50 AM   #12
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 91

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Up to my knowledge, the client has been providing us the code in executable format i.e., in JAVA code and some of them in perl executable format.

Basically, the script invokes the build process steps and executes the complete build process through command line. So, we already have the GUI to run the same.

Probably, they have the partial scripts in-place to run the same from some other tools.
 
Old 04-09-2017, 05:56 AM   #13
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,524
Blog Entries: 3

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
Thanks. It still does not make sense on any level to me, especially since perl does not compile per se. But it sounds like you can take a look at the -u option pan64 mentioned and at the link I added above. If that's not what you mean then you'll have to explain more about these tools you are trying to fit things into.
 
Old 04-09-2017, 11:09 PM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187
"Don't blame Perl." (All such languages have had very-similar experiences.)

The differences between "the intended execution-environment of a <<X>>-script" (which is by definition very contextual), and "an executable," (which is by definition "context-free"), usually turn out to be insurmountable in practice.

"Apples are tasty." "So are Oranges!" But: "Apples are not Oranges!"

Both of these "equally-tasty fruits" are the products of very(!) different approaches.

... "so different, in fact, that ..." (IMHO) it really does not make sense to try to combine the two.

Each approach makes perfect engineering sense in its own intended context, but is engineering-nonsensical (IMHO) in the other.

"So ... don't push it."

Last edited by sundialsvcs; 04-09-2017 at 11:19 PM.
 
Old 04-29-2017, 09:10 AM   #15
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 91

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
There are lot of utilities available in online for creating an exe out of a perl script. So, tried several options and pp(PAR::Packer) looks like a simple tool to convert. But, it generated a 32 bit compatible exe though I use 64 bit Ubuntu and Machine, nothing worked for me with the latest versions of Perl packages.

So, People here wanted to know why I need an exe etc ?

Now, my question here is why not and exe ?
Quote:
You wrote a killer
application in Perl.
But you are its only user!
Can’t get it out to the
masses. . .
Solution:
Marketing
Make it easy as hell to
run the application.
As I was not able to generate an exe I took help from one of my senior member and he created it in an hour with same PP utility. So, tried contacting him several time. But, he is on a long vacation and Now, I need to create one with out his help(its a great challenge for me. But, it is not working at all(frustrated!))

Please respond to the thread if you have any guidance in creating an exe for a perl script.

Last edited by rpittala; 04-29-2017 at 10:12 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 06:00 AM
How Can I convert Hex to Binary in a perl script telecom_is_me Programming 18 10-11-2010 04:34 PM
Perl script dieing while waiting on select() for some response from another exe rajeshkdugar Programming 1 04-22-2010 02:56 AM
how to use perl.exe in shell script littletransformer Programming 7 12-03-2007 03:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration