Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

PAR pp error when executing created file

by g_speran (Scribe)
on Mar 02, 2021 at 00:58 UTC ( [id://11128976]=perlquestion: print w/replies, xml ) Need Help??

g_speran has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monk....I seek your wisdom I am trying to use pp to package a file and a script into a file called iDPAswitch.exe the command I use is:
pp -o iDPAswitch.exe -a #iDPA_SW_Template220 iDPAswitch-2_3_0.pl
it seems to package fine until I execute th iDPAswitch.exe file. I get the below error
error: member not found at script/main.pl line 26. Extract of iDPAswitch.exe failed
I have tried altering the syntax as follows to include non-core modules & core modules needed
pp -o -B iDPAswitch.exe -a #iDPA_SW_Template220 iDPAswitch-2_3_0.pl
I get the same "member not found error". I have opened iDPAswitch.exe with 7-zip and confirmed that iDPAswitch-2_3_0.pl is in the scripts directory and the Template file included is one level up/back The contents of main.pl are as follows
if (defined $ENV{PAR_APP_REUSE}) { warn "Executable was created without the --reusable option. See 'p +erldoc pp'.\n"; exit(1); } my $zip = $PAR::LibCache{$ENV{PAR_PROGNAME}} || Archive::Zip->new(__FI +LE__); my $member = eval { $zip->memberNamed('script/iDPAswitch-2_3_0.pl') } or die qq(main.pl: Can't open perl script "script/iDPAswitch-2 +_3_0.pl": No such file or directory ($zip)); # Remove everything but PAR hooks from @INC my %keep = ( \&PAR::find_par => 1, \&PAR::find_par_last => 1, ); my $par_temp_dir = File::Spec->catdir( $ENV{PAR_TEMP} ); @INC = grep { exists($keep{$_}) or $_ =~ /^\Q$par_temp_dir\E/; } @INC; PAR::_run_member($member, 1);
How can I identify what "member not found" its failing on and how to rectify it

Thanks in Advance....

Replies are listed 'Best First'.
Re: PAR pp error when executing created file
by g_speran (Scribe) on Mar 02, 2021 at 14:09 UTC
    Sorry All! I thought I actually posted this last night. seems that I constructed to post it, but only reviewed my posting and never actually post it

    I have rectified my situation. It was actually a coding issue with my script, not main.pl. I neglected to have a variable $MODFILE defined and it looked like that main.pl was erroring out.

    for education and documentation purposes, I am attaching the code that was causing the failure and I added more verbiage to the error.

    sub Extract_Template { if ($ScriptName =~ /\.exe$/i) { my $zip = Archive::Zip->new(); my $status = $zip->read( $ScriptName ); die "Read of $ScriptName failed\n" if $status != AZ_OK; $status = $zip->extractMemberWithoutPaths($MODFILE); die "Extraction of Template File \"$MODFILE\" within $ScriptNa +me failed\n EXITING\n" if $status != AZ_OK; } }

    Again...my apologies

Re: PAR pp error when executing created file
by swl (Parson) on Mar 02, 2021 at 06:30 UTC

    How are you trying to access the file in your code?

    Once it is unpacked it will be in the inc dir under the directory name in $ENV{PAR_TEMP}. You can check if you are running under PAR by using $ENV{PAR_0}.

    For example:

    use strict; use warnings; my $fname = '#iDPA_SW_Template220'; my $file = $ENV{PAR_0} ? "$ENV{PAR_TEMP}/inc/$fname" : $fname; open my $fh, $file or die "Cannot open $file"; # do stuff with $fh

    Update:

    Although now I read the error properly it is an issue with the main run.

    Which versions of perl, PAR and PAR::Packer are you using? And perhaps also Archive::Zip.

    There are also some old reports with similar errors, one of which seems to be long fixed but which needed module updates.

    https://rt.cpan.org/Public/Bug/Display.html?id=72837

    https://www.nntp.perl.org/group/perl.par/2006/12/msg2759.html

Re: PAR pp error when executing created file
by Discipulus (Canon) on Mar 02, 2021 at 07:28 UTC
    Hello g_speran,

    I have no time to reproduce it atm, but if I recall it correctly included content is flattened into / so no /script folder will be accessible.

    From the docs

    > By default, files are placed under / inside the package with their original names.

    After this I remember there are other methods to access included files, even if I never included a perl script. Why you dont wrap your code inside a small madule including it in a simpler way and then adding the use of this module inside your main script?

    Again from the docs

    # To get the host archive from a packed program: my $zip = PAR::par_handle($0); # an Archive::Zip object my $content = $zip->contents('MANIFEST'); # Same thing, but with read_file(): my $content = PAR::read_file('MANIFEST');

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: PAR pp error when executing created file
by Anonymous Monk on Mar 02, 2021 at 04:25 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11128976]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found