Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

PAR pp error when executing created file

by g_speran (Beadle)
on Mar 02, 2021 at 00:58 UTC ( #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
it seems to package fine until I execute th iDPAswitch.exe file. I get the below error
error: member not found at script/ 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
I get the same "member not found error". I have opened iDPAswitch.exe with 7-zip and confirmed that is in the scripts directory and the Template file included is one level up/back The contents of 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/') } or die qq( Can't open perl script "script/iDPAswitch-2": 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 swl (Priest) 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


    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.

Re: PAR pp error when executing created file
by g_speran (Beadle) 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 I neglected to have a variable $MODFILE defined and it looked like that 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; } } apologies

Re: PAR pp error when executing created file
by Discipulus (Abbot) 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');


    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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2021-05-05 21:51 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (69 votes). Check out past polls.