LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 05-14-2006, 10:01 AM   #1
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Rep: Reputation: 30
executable format...


Hello, this is my first post in linuxquestions community.
I realized a perl script for Linux distributions and I would distribute this software in executable format, but at moment I would not distribute the source file.
Exist it a method to converte the perl script in executable format?

Thanks anyone for answers.

Shifter
 
Old 05-14-2006, 10:45 AM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
It is possible to compile Perl scripts into executable binaries. You actually have two options there: to compile to Perl bytecode (which will be executed by the client's Perl interpreter) and to native instructions (by generating and compiling C code). See the perlcc manual page for more information. Note the manual page's disclaimer on the experimental nature of this feature. Also, keep in mind that any time you distribute binary-only distributions you decrease the audience that can use your application.

And welcome to LinuxQuestions.
 
Old 05-14-2006, 12:18 PM   #3
nhydra
Member
 
Registered: May 2006
Distribution: Fedora Core, FreeSpire, PC-BSD, NetBSD
Posts: 96

Rep: Reputation: 15
Just a notice. I compiled a perl script and i had a segmentation fault when the file was executed. So you have to take a look about this programming.
More information about that is here:
http://perldoc.perl.org/index-tutorials.html
 
Old 05-15-2006, 02:11 AM   #4
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Can I create a executable program with sh script also?
 
Old 05-15-2006, 02:25 AM   #5
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
1)
Quote:
Originally Posted by shifter
Also, keep in mind that any time you distribute binary-only distributions you decrease the audience that can use your application.
I must to distribute a program with proprietary license...
2)
Can I create a executable program with sh script also?
 
Old 05-15-2006, 02:27 AM   #6
nhydra
Member
 
Registered: May 2006
Distribution: Fedora Core, FreeSpire, PC-BSD, NetBSD
Posts: 96

Rep: Reputation: 15
1. You can include your license in the program. For open source program suitable are BSD and GPL licenses. 2. You mean to have a simple shell script that work like a program? If yes, probably you can. The nVIDIA graphics drivers are made in SHELL script.It is only a shell script that make all the things like a program. The script is very big. Almost 10 Mb. You can't write so big script. I suspect there is a program for this. Just an idea. Can you make a C/C++ program and a SHELL scrip that manage this program? In that way you have a compiled source code and a shell script that run and manage your program. It is simple to be done and useful.

Last edited by nhydra; 05-15-2006 at 02:39 AM.
 
Old 05-15-2006, 03:51 AM   #7
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Quote:
1. You can include your license in the program. For open source program suitable are BSD and GPL licenses.
I would distribuite my script in executable format only and with proprietary license.
 
Old 05-15-2006, 04:01 AM   #8
nhydra
Member
 
Registered: May 2006
Distribution: Fedora Core, FreeSpire, PC-BSD, NetBSD
Posts: 96

Rep: Reputation: 15
You can base your license on some ready license or can make new license for yourself. Many people base thems licenses on the BSD license and include additional conditions.
 
Old 05-15-2006, 09:15 AM   #9
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
nhydra: I believe nVidia's drivers are distributed in a single file composed of both the installation script and the binary data. That is why the file is so large. When you run the file, your shell begins stepping through the script, until it hits a command that uses most of the rest of the data as binary input. Because utilities like tar and gzip can take data in on standard input, it is possible to "hard-code" this data inline into the file and then pass it through the decompression utility inside the interpreted script. Another alternative would be to issue a command from the script that uses the script itself as input, disregarding the first n lines, which are not binary (i.e. they are interpreted by the shell). These methods do not hide the details of the installation mechanism, but they do keep the drivers binary and make it easier for a user to install (since they only have to worry about one file).

Shifter: I remember a question about converting a shell script into a binary here on LinuxQuestions some time ago, but I can't seem to find it. Doing a Google search may reveal a program that will convert it (from source script to binary) for you, but I think it would be easier to use an alternate method. The difference between shell and Perl is that Perl is actually compiled into an intermediary non-human-readable binary format (bytecode) and then executed; it's kind of like a Java class (IIRC) except the bytecode is recompiled every time it's run. Shell, on the other hand, is simply a list of text commands; it is not compiled in any way. Therefore, there are no builtin ways to compile a binary version of a shell script (because shells simply don't work that way). An alternative, then, would be to somehow encrypt your script and place it into a separate file. You can then use a binary program (a Perl script, or C++ program, for example) to decrypt the file and pass each command, one by one, to a shell interpreter. (Make sure to disable the history on this shell, first!) This would accomplish your goal of keeping the script's actions secret.
 
Old 05-15-2006, 12:05 PM   #10
DanTaylor
Member
 
Registered: Jan 2006
Distribution: Debian Sarge
Posts: 265

Rep: Reputation: 30
You can try using perl2exe - a free version is available.
 
  


Reply



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
gdb "not in executable format: File format not recognized" tcma Programming 9 07-18-2007 06:02 AM
executable file format arunka Programming 2 03-15-2006 05:24 AM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
kernel 2.6.3 compile ends in grub error 13: unsupported executable format(?) browny_amiga Linux - General 4 03-06-2004 02:33 PM
Executable format on Linux and FreeBSD llama_meme *BSD 1 10-02-2002 11:24 AM

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

All times are GMT -5. The time now is 06:59 AM.

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