【发布时间】:2015-04-30 20:44:50
【问题描述】:
我有一个使用以下 Perl 脚本安装的程序。安装不起作用,我收到消息“未找到安装程序”。显然,没有做任何事情,因为脚本只是简单地死了。
这是 Perl 安装脚本(用于安装一个名为 Simics 的程序):
#!/usr/bin/perl
use strict;
use warnings;
# Find the most recent installer in the current working directory.
my $installer;
my $highest_build = 0;
opendir my $d, "." or die $!;
foreach (readdir $d) {
if (-f && -x && /^build-(\d+)-installer/) {
if ($1 > $highest_build) {
$highest_build = $1;
$installer = $_;
}
}
}
closedir $d;
die "No installers found.\n" unless defined $installer;
exec "./$installer", @ARGV;
【问题讨论】:
-
脚本希望在您的当前目录中找到一个名为
build-###-installer(其中###是某个数字)的程序。你有这样的文件吗? -
@Barmar:是的,有。该文件是 build-4607-installer.pl。我想知道为什么脚本没有看到它?我不懂 Pearl 脚本语言。
-
可执行吗?文件测试在定义
$installer之前需要-x。 -
我刚刚在我的 Linux 机器上复制了你上面的大部分代码,它工作正常。让我相信,就像上面的 G. Cito 一样,这一定是安装程序烫发的问题。请发布
ls -al build-4607-installer.pl的输出,以便我们查看文件上的权限... -
谢谢。输出为
-rw------- 1 nikk nikk 52238 Feb 27 20:50 build-4607-installer.pl
标签: linux perl scripting installation simics