Where Does Pp (Par) Unpack Add (-A) Files

Where does pp (PAR) unpack add (-a) files?

The files in a packaged executable are extracted to a temporary directory (usually /tmp/par-USERNAME/cache-XXXXXXX).
To access these files do something like the following:

#!/usr/bin/perl

# Reads a data file from the archive (added with -a)
print PAR::read_file("data");

# Will execute "script2" in the archive and exit. Will not return to this script.
require PAR;
PAR->import( { file => $0, run => 'script2' } );

You can also make symolic links to the executable that have the same name as the script you want to run, and run those.

Actually, rereading your question, simply accessing the PAR_TEMP environment variable is probably more useful:

#!/usr/bin/perl
use File::Slurp qw(slurp);

$data_dir = "$ENV{PAR_TEMP}/inc";
$script_dir = "$data_dir/script";

print slurp("$data_dir/datafile");

# file access permissions are not preserved as far as I can tell,
# so you'll have to invoke the interpreter explicitly.
system 'perl', "$script_dir/script2", @args;

How to add all dependencies of Perl DBI module to PAR packer archive

The following part of the error message:

libmysqlclient.so.20: cannot open shared object file: No such file or directory

...typically means that the MySQL client library is not installed on the system you're attempting to unpack/install onto, so you need to install it. For example, on Ubuntu:

sudo apt-get install mysql-client

Perl: How do I add encoding to PAR packed archive

You should add the modules directly in your code.

use Encode qw(:all);

use Encode::Byte;
use Encode::CN;
use Encode::JP;
use Encode::KR;
use Encode::TW;

my @list = Encode->encodings();
print join("\n", @list);

Why don't my system calls work in the Perl program I wrap with pp?

Update: My suggestions below do not work. However, I am going to leave them up in case someone else has a similar question. This answer shows a lot of things that may sound reasonable but do not work.

See the discussion following the OP's repost for code using $ENV{PAR_TEMP} that solves the OP's problem

FOR REFERENCE

pp docs say:

-a, --addfile=FILE|DIR
...

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

By using system, you are asking cmd.exe to find the file and I now realize that probably is a losing battle unless you have a separate executable called cpau.exe. I do not have time to try this right now, but a you might have to do the fork and exec yourself instead of relying on system. As in:

exec 'CPAU.exe', @args

Previous answer:

The string you pass to system does not contain what you think it does:

use strict;
use warnings;

my $x= "..\cpau -dec -file ..\add_rec.job -nowarn -wait";

print $x, "\n";
__END__

C:\Temp> fgh
..►au -dec -file ..dd_rec.job -nowarn -wait

Use (edited following OP's comment below):

system "..\\cpau -dec -file ../add_rec.job -nowarn -wait";

I would also recommend using the list form of system:

system '..\\cpau', qw(-dec -file ../add_rec.job -nowarn -wait);

In addition, you might find FindBin handy if you want to specify the path to cpau relative to the current script's directory.

For example:

#!/usr/bin/perl

use strict;
use warnings;

use FindBin qw($Bin);
use File::Spec::Functions qw( catfile );

my $program = catfile $Bin, '..', 'cpau';

system $program, qw(-dec -file ../add_rec.job -nowarn -wait);

__END__

Converting a .exe to .pl in Perl?

Rename .exe to .zip and check if files can be extracted



Related Topics



Leave a reply



Submit