Operating System - HP-UX
1755254 Members
5549 Online
108831 Solutions
New Discussion юеВ

Converting/executing a PERL script in binaries

 
Peter Remirez
Occasional Advisor

Converting/executing a PERL script in binaries

HI,

I'm wanting to execute my PERL script in a binary/executable form. I wrote a C wrapper to do so. However, when executing the binary code produced by the wrapper, it produced the warning message as:
1073741825 version 1 is not available
ELEMENTS: 1073741826 1 udp 756 program 1073741826 version 1 is not available
1073741826
1
udp
756
program

1073741826 version 1 is not available
ELEMENTS: 1073741827 1 udp 813 program 1073741827 version 1 is not available
1073741827
1
udp
813
program

1073741827 version 1 is not available
Sending mail now ...
The flags you gave make no sense since you're not sending mail.

However, when executing just the script itself, the script did not produce the warning "The flags you gave make no sense since you're not sending mail. ". The output is shown below:
pgadm1@penang[13]% file-61.pl names
/pgadm1/usr1/adm/cleaw/script/test/WEIRDER opened successfully
$names[0]=cleaw
$list= cleaw@pinang.png.intel.com
HERE ...
ELEMENTS: 1073741824 1 udp 661 program 1073741824 version 1 is not available
ELEMENTS: 1073741825 1 udp 899 program 1073741825 version 1 is not available
ELEMENTS: 1073741826 1 udp 756 program 1073741826 version 1 is not available
ELEMENTS: 1073741827 1 udp 813 program 1073741827 version 1 is not available
Sending mail now ...

SUBJECT: RPCPING OUTPUT
HOST :pgadm1
IP :172.30.209.15
OS :aix
PROG NO VER PROTO PORT SERVICE RESPONSE
1073741824 1 udp 661 program 1073741824 version 1 is not available
1073741825 1 udp 899 program 1073741825 version 1 is not available
1073741826 1 udp 756 program 1073741826 version 1 is not available
1073741827 1 udp 813 program 1073741827 version 1 is not available

I was wondering if someone could show me how I could convert a PERL script into a binary code? Or if the way that I've wrote my wrapper is wrong, kindly correct me.
Are there any perl functions or modules which converts a PERL script into a binary code?

Attached also are both my perl script(file-6.pl). Below is wrapper code written in C.

Could someone kindly help me out?

Thanks
#include
#include
#include
#include
#include

int main(int argc, char**argv){
char**a = (char**)malloc(10);
a[0] = (char*)malloc(50);
a[1] = (char*)malloc(50);
a[2] = NULL;

strcpy(a[0], "/pgadm1/adm/cleaw/script/test/names");
execv("/pgadm1/adm/cleaw/script/test/file-6.pl",a);
perror("execv");
exit(1);
}

2 REPLIES 2
Max_4
Frequent Advisor

Re: Converting/executing a PERL script in binaries

Hi,

Have you taken a look at perlcc?
I was trying it but failed at link time.
Because ld was unable to find some lib...
But maybe you can try further with your code...

I'd also recommend removing the explicit casts
from your malloc() calls, it's not necessary
since malloc returns a void *. But fortunately
you've included stdlib.h.

Hope it helps you a bit....

Manuel
A. Clay Stephenson
Acclaimed Contributor

Re: Converting/executing a PERL script in binaries

Ther first thing that I notice is that your Perl is expecting to read command line arguments but you haven't supplied them. I don't know what you are trying to accomplish since you still have to use the Perl source -- this really isn't a standalone executable.

A rather good Perl to native convertor is
Perl2exe available rather cheaply from www.indigostar.com.
If it ain't broke, I can fix that.