Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux pp(PAR)在哪里解压缩add(-a)文件?_Linux_Perl_Par_Perl Packager - Fatal编程技术网

Linux pp(PAR)在哪里解压缩add(-a)文件?

Linux pp(PAR)在哪里解压缩add(-a)文件?,linux,perl,par,perl-packager,Linux,Perl,Par,Perl Packager,这是我试图解决提出的无关问题的尝试。我在linux系统上创建了一个简单的Perl脚本: new-net:~/scripts # cat ls_test.pl @ls_out = `ls -l`; map { print "$_\n" } @ls_out; $out = `sh out_test.sh`; print "$out\n"; 此脚本调用一个简单的shell文件: new-net:~/scripts # cat out_test.sh echo "I'm here" 我使用pp

这是我试图解决提出的无关问题的尝试。我在linux系统上创建了一个简单的Perl脚本:

new-net:~/scripts # cat ls_test.pl
@ls_out = `ls -l`;

map { print "$_\n" } @ls_out;

$out = `sh out_test.sh`;

print "$out\n";
此脚本调用一个简单的shell文件:

new-net:~/scripts # cat out_test.sh
echo "I'm here"
我使用pp将Perl脚本和shell脚本打包到ls_测试中:

new-net:~/test # unzip -l ls_test Archive: ls_test Length Date Time Name -------- ---- ---- ---- 0 07-13-09 16:41 script/ 436 07-13-09 16:41 MANIFEST 214 07-13-09 16:41 META.yml 93 07-13-09 16:41 script/ls_test.pl 538 07-13-09 16:41 script/main.pl 16 07-13-09 16:20 out_test.sh -------- ------- 1297 6 files 新网络:~/test#解压-l ls#u测试 存档:ls_测试 长度日期时间名称 -------- ---- ---- ---- 0 07-13-09 16:41脚本/ 43607-13-0916:41舱单 214 07-13-09 16:41梅塔 93 07-13-09 16:41脚本/ls_test.pl 538 07-13-09 16:41脚本/main.pl 16 07-13-09 16:20 out_test.sh -------- ------- 12976个文件 如果在其他空目录中运行打包文件,则找不到shell脚本:

new-net:~/test # ./ls_test total 3391 -rwxr-xr-x 1 root root 3466177 Jul 13 16:41 ls_test sh: out_test.sh: No such file or directory 新网络:~/test#/ls#u测试 总数3391 -rwxr-xr-x 1根根目录3466177 7月13日16:41 ls_测试 sh:out_test.sh:没有这样的文件或目录 如果我将shell脚本复制到目录中,打包脚本将按预期运行:

new-net:~/test # ./ls_test
total 3395 -rwxr-xr-x 1 root root 3466177 Jul 13 16:41 ls_test -rw-r--r-- 1 root root 16 Jul 13 16:20 out_test.sh I'm here 新网络:~/test#/ls#u测试
总数3395 -rwxr-xr-x 1根根目录3466177 7月13日16:41 ls_测试 -rw-r--r--1根根系7月16日13:20 out_test.sh 我在这里
那么,
pp
packed脚本希望在哪里找到包含的文件呢?在原始Perl脚本中如何配置对所包含文件的调用?

打包的可执行文件中的文件被提取到临时目录(通常为/tmp/par USERNAME/cache-xxxxxx)。 要访问这些文件,请执行以下操作:

#!/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' } );
您还可以创建指向与要运行的脚本同名的可执行文件的符号链接,然后运行这些链接

实际上,重读您的问题,简单地访问PAR_TEMP环境变量可能更有用:

#!/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;

以下是在我的系统中起作用的内容:

C:\tmp> cat build.bat @echo off mkdir output call pp -o runner.exe runner.pl -a sayhello.bat move runner.exe output\runner.exe C:\tmp>cat build.bat @回音 mkdir输出 调用pp-o runner.exe runner.pl-a sayhello.bat 移动runner.exe输出\runner.exe C:\tmp>cat sayhello.bat @我在说你好。。。
C:\tmp>cat runner.pl
#!/usr/bin/perl
严格使用;
使用警告;
使用File::Spec::Functions qw(catfile);
my$prog_path=catfile$ENV{PAR_TEMP},inc=>'sayhello.bat';
my$output=`$prog_path`;

print“输出为:>>>$output感谢大家对这个答案的贡献。我添加这个答案是为了提炼出每个人宝贵的输入中的部分,我曾经提出过在我的特定应用程序中对我有用的解决方案

该应用程序使用POE和Tk以ActiveState Perl编写,并使用pp打包分发。它使用多个外部文件;一些用于输入程序(从DNS提取数据),另一些用于用户采取的操作(创建和删除DNS别名记录)

PAR PACKER(PP)包含使用-A参数的外部文件。这些文件在包创建的“临时”路径中被解压缩到\Inc目录中,并通过

提供给脚本。
$ENV{PAR_TEMP}
解决方案的第一步是将此信息添加到POE“$heap”中。下面的行处于串联状态“\u start”

在Win32环境中工作时,我使用转义反斜杠将\inc目录附加到临时路径中

在调用外部文件以输入应用程序时,我使用了一个变量(@zone)来返回数据

@zone = `$heap->{t_path}dnscmd aus-dc1 /enumrecords company.pvt @`;
对于完成外部操作的调用,调用文件时不保存输出

`$heap->{t_path}cpau -dec -file $heap->{t_path}del_event.job -nowarn -wait`;

再次感谢大家对StAcExpRoad的贡献和感谢,提供了这个伟大的环境。

从PelDoc PAR;运行一个脚本的名字在Par中运行。退出后,这是否意味着对一个附加文件的任何调用都退出打包脚本?我最初试图解决的问题是一个POE/TK脚本调用VALUOU默认的缓存/临时目录类似于MWSUDOWS。默认的缓存/临时目录是当前目录。NoPc\\DOMUME \ 1个用户名\Loals~ 1 \TEMP\PAR用户名\ CACHE-07B6C42D8FD8DD8ABD88EB8B67 BF7ECAB……但是,您的评论使我意识到我忘记了在帖子中修改<代码> Bug < B/C> >。EMP是脏的?我没有找到任何其他方法来引用提取目录。你当然可以自己提取存档,然后你知道它在哪里。不是…感觉…有点…无论如何,考虑到我没有任何运气使用
fsutil hardlink create
,这似乎是唯一的选择。我可以看出使用PAR_TEMP可能有点麻烦脏,因为它没有提到无论是在PAR的页面或PPP的一个。但我怀疑它会消失,因为它是方便的。使用<代码>文件::规格-> CATFILE($Env {PARI TMOP},‘Inc’)
而不是搞双重反斜杠。顺便说一句,我有点惊讶的是,我是这个帖子中唯一一个对任何答案投了高票的人:你表达感激的方式就是对答案投高票。
$ENV{PAR_TEMP}
$heap->{t_path} = "$ENV{PAR_TEMP}\\inc\\";
@zone = `$heap->{t_path}dnscmd aus-dc1 /enumrecords company.pvt @`;
`$heap->{t_path}cpau -dec -file $heap->{t_path}del_event.job -nowarn -wait`;